<!DOCTYPE html><html><head><title>Coverage</title><meta charset="utf-8"><script>

headings = [];

onload = function(){
  headings = document.querySelectorAll('h2');
};

onscroll = function(e){
  var heading = find(window.scrollY);
  if (!heading) return;
  var links = document.querySelectorAll('#menu a')
    , link;

  for (var i = 0, len = links.length; i < len; ++i) {
    link = links[i];
    link.className = link.getAttribute('href') == '#' + heading.id
      ? 'active'
      : '';
  }
};

function find(y) {
  var i = headings.length
    , heading;

  while (i--) {
    heading = headings[i];
    if (y >= heading.offsetTop) {
      return heading;
    }
  }
}
</script>
<style>

body {
  font: 14px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 0;
  color: #2C2C2C;
  border-top: 2px solid #ddd;
}

#coverage {
  padding: 60px 400px 60px 60px;
}

h1 a {
  color: inherit;
  font-weight: inherit;
}

h1 a:hover {
  text-decoration: none;
}

.onload h1 {
  opacity: 1;
}

h2 {
  width: 80%;
  margin-top: 80px;
  margin-bottom: 0;
  font-weight: 100;
  letter-spacing: 1px;
  border-bottom: 1px solid #eee;
}

a {
  color: #8A6343;
  font-weight: bold;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul {
  margin-top: 20px;
  padding: 0 15px;
  width: 100%;
}

ul li {
  float: left;
  width: 40%;
  margin-top: 5px;
  margin-right: 60px;
  list-style: none;
  border-bottom: 1px solid #eee;
  padding: 5px 0;
  font-size: 12px;
}

ul::after {
  content: '.';
  height: 0;
  display: block;
  visibility: hidden;
  clear: both;
}

code {
  font: 12px monaco, monospace;
}

pre {
  margin: 30px;
  padding: 30px;
  border: 1px solid #eee;
  border-bottom-color: #ddd;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  border-radius: 2px;
  -webkit-box-shadow: inset 0 0 10px #eee;
  -moz-box-shadow: inset 0 0 10px #eee;
  box-shadow: inset 0 0 10px #eee;
  overflow-x: auto;
}

img {
  margin: 30px;
  padding: 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  -webkit-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  -moz-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  max-width: 100%;
}

footer {
  background: #eee;
  width: 100%;
  padding: 50px 0;
  text-align: right;
  border-top: 1px solid #ddd;
}

footer span {
  display: block;
  margin-right: 30px;
  color: #888;
  font-size: 12px;
}

#menu {
  position: fixed;
  font-size: 12px;
  overflow-y: auto;
  top: 0;
  right: 0;
  margin: 0;
  height: 100%;
  padding: 15px 0;
  text-align: right;
  border-left: 1px solid #eee;
  max-width: 400px;
  overflow: auto;
  white-space: nowrap;
  
  -moz-box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  -webkit-box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  -webkit-font-smoothing: antialiased;
  background: url("");
}

#menu::after {
  display: block;
  content: '';
  padding-top: 80px;
}

#logo {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background: rgba(255,255,255,.1);
  font-size: 11px;
  display: block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  -webkit-border-radius: 20px;
  -moz-border-radius: 20px;
  border-radius: 20px;
  -webkit-box-shadow: 0 0 3px rgba(0,0,0,.2);
  -moz-box-shadow: 0 0 3px rgba(0,0,0,.2);
  box-shadow: 0 0 3px rgba(0,0,0,.2);
  color: inherit;
}

#menu li a {
  display: block;
  color: white;
  padding: 0 35px 0 25px;
  -webkit-transition: background 300ms;
  -moz-transition: background 300ms;
}

#menu li {
  position: relative;
  list-style: none;
}

#menu a:hover,
#menu a.active {
  text-decoration: none;
  background: rgba(255,255,255,.1);
}

#menu li:hover .cov {
  opacity: 1;
}

#menu li .dirname {
  opacity: .60;
  padding-right: 2px;
}

#menu li .basename {
  opacity: 1;
}

#menu .cov {
  background: rgba(0,0,0,.4);
  position: absolute;
  top: 0;
  right: 8px;
  font-size: 9px;
  opacity: .6;
  text-align: left;
  width: 17px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
  padding: 2px 3px;
  text-align: center;
}

#stats:nth-child(2n) {
  display: inline-block;
  margin-top: 15px;
  border: 1px solid #eee;
  padding: 10px;
  -webkit-box-shadow: inset 0 0 2px #eee;
  -moz-box-shadow: inset 0 0 2px #eee;
  box-shadow: inset 0 0 2px #eee;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
}

#stats div {
  float: left;
  padding: 0 5px;
}

#stats::after {
  display: block;
  content: '';
  clear: both;
}

#stats .sloc::after {
  content: ' SLOC';
  color: #b6b6b6;
}

#stats .percentage::after {
  content: ' coverage';
  color: #b6b6b6;
}

#stats .hits,
#stats .misses {
  display: none;
}

.high {
  color: #00d4b4;
}
.medium {
  color: #e87d0d;
}
.low {
  color: #d4081a;
}
.terrible {
  color: #d4081a;
  font-weight: bold;
}

table {
  width: 80%;
  margin-top: 10px;
  border-collapse: collapse;
  border: 1px solid #cbcbcb;
  color: #363636;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}

table thead {
  display: none;
}

table td.line,
table td.hits {
  width: 20px;
  background: #eaeaea;
  text-align: center;
  font-size: 11px;
  padding: 0 10px;
  color: #949494;
}

table td.hits {
  width: 10px;
  padding: 2px 5px;
  color: rgba(0,0,0,.2);
  background: #f0f0f0;
}

tr.miss td.line,
tr.miss td.hits {
  background: #e6c3c7;
}

tr.miss td {
  background: #f8d5d8;
}

td.source {
  padding-left: 15px;
  line-height: 15px;
  white-space: pre;
  font: 12px monaco, monospace;
}

code .comment { color: #ddd }
code .init { color: #2F6FAD }
code .string { color: #5890AD }
code .keyword { color: #8A6343 }
code .number { color: #2F6FAD }
</style>
</head><body><div id="coverage"><h1 id="overview">Coverage</h1><div id="menu"><li><a href="#overview">overview</a></li><li><span class="cov high">84</span><a href="#api/bucket.js"><span class="dirname">api/</span><span class="basename">bucket.js</span></a></li><li><span class="cov high">87</span><a href="#api/download.js"><span class="dirname">api/</span><span class="basename">download.js</span></a></li><li><span class="cov high">85</span><a href="#api/object.js"><span class="dirname">api/</span><span class="basename">object.js</span></a></li><li><span class="cov high">100</span><a href="#api/service.js"><span class="dirname">api/</span><span class="basename">service.js</span></a></li><li><span class="cov high">86</span><a href="#api/upload.js"><span class="dirname">api/</span><span class="basename">upload.js</span></a></li><li><span class="cov high">91</span><a href="#auth.js"><span class="basename">auth.js</span></a></li><li><span class="cov high">100</span><a href="#ks3.js"><span class="basename">ks3.js</span></a></li><li><span class="cov high">95</span><a href="#request.js"><span class="basename">request.js</span></a></li><li><span class="cov medium">71</span><a href="#util.js"><span class="basename">util.js</span></a></li><a id="logo" href="http://mochajs.org/">m</a></div><div id="stats" class="high"><div class="percentage">83%</div><div class="sloc">1024</div><div class="hits">858</div><div class="misses">166</div></div><div id="files"><div class="file"><h2 id="api/bucket.js">api/bucket.js</h2><div id="stats" class="high"><div class="percentage">84%</div><div class="sloc">149</div><div class="hits">126</div><div class="misses">23</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var request = require('./../request');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var auth = require('./../auth');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var config = require('./../../config');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var util = require('./../util');</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> * &#21019;&#24314;&#21333;&#20010;Bucket</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> * @param {object} params</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> *		Bucket: '' &#24517;&#39035;&#20256;&#65292;&#35201;&#21019;&#24314;&#30340;bucketName	</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source"> *		ACL: '', // bucket&#26435;&#38480;&#35774;&#32622; ['private' || 'public-read' || 'public-read-write' || 'authenticated-read']	</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> *	}</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">14</td><td class="hits">1</td><td class="source">function put(params, cb) {</td></tr><tr class="hit"><td class="line">15</td><td class="hits">34</td><td class="source">	var bName = this.bucketName;</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">17</td><td class="hits">34</td><td class="source">	var bucketName = (function(){</td></tr><tr class="hit"><td class="line">18</td><td class="hits">34</td><td class="source">		var s = bName;</td></tr><tr class="hit"><td class="line">19</td><td class="hits">34</td><td class="source">		if(!!params &amp;&amp; params.Bucket){</td></tr><tr class="hit"><td class="line">20</td><td class="hits">3</td><td class="source">			s = params.Bucket</td></tr><tr><td class="line">21</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source">		</td></tr><tr class="hit"><td class="line">23</td><td class="hits">34</td><td class="source">		return s;</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source">	})();</td></tr><tr class="hit"><td class="line">25</td><td class="hits">34</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">26</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr class="hit"><td class="line">27</td><td class="hits">34</td><td class="source">	} else if(!util.verifyBucket(bucketName)) {</td></tr><tr class="hit"><td class="line">28</td><td class="hits">1</td><td class="source">		throw new Error('the illegal bucketName');</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">31</td><td class="hits">33</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr class="hit"><td class="line">32</td><td class="hits">33</td><td class="source">	var resource = '/';</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source">	</td></tr><tr class="hit"><td class="line">34</td><td class="hits">33</td><td class="source">	var req = {</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">41</td><td class="hits">33</td><td class="source">	if(params &amp;&amp; params.ACL) {</td></tr><tr class="hit"><td class="line">42</td><td class="hits">1</td><td class="source">		var acl = params.ACL,</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">			attr_Acl = 'x-'+config.prefix+'-acl';</td></tr><tr class="hit"><td class="line">44</td><td class="hits">1</td><td class="source">		if(util.verifyAcl(acl) == null) {</td></tr><tr class="hit"><td class="line">45</td><td class="hits">1</td><td class="source">			throw new Error('the illegal acl');</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">		}</td></tr><tr class="miss"><td class="line">47</td><td class="hits">0</td><td class="source">		req.headers = {</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">			attr_Acl: acl</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">		};</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">52</td><td class="hits">32</td><td class="source">	var body = getCreateBucketConfiguration(config.region);</td></tr><tr class="hit"><td class="line">53</td><td class="hits">32</td><td class="source">	if(body){</td></tr><tr class="hit"><td class="line">54</td><td class="hits">32</td><td class="source">		req.type = 'text/xml';</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">56</td><td class="hits">32</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">58</td><td class="hits">32</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">60</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source"> * &#33719;&#24471;&#21019;&#24314;bucket&#26102;&#29992;&#20110;&#35774;&#32622;region&#30340;&#35831;&#27714;&#20307;</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source"> * @param region</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">65</td><td class="hits">1</td><td class="source">function getCreateBucketConfiguration(region){</td></tr><tr class="hit"><td class="line">66</td><td class="hits">32</td><td class="source">	if(!region){</td></tr><tr class="miss"><td class="line">67</td><td class="hits">0</td><td class="source">		return null;</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">70</td><td class="hits">32</td><td class="source">	return '&lt;CreateBucketConfiguration xmlns=&quot;http://s3.amazonaws.com/doc/2006-03-01/&quot;&gt;&lt;LocationConstraint&gt;' + region + '&lt;/LocationConstraint&gt;&lt;/CreateBucketConfiguration&gt;';</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source"> * &#33719;&#21462;bucket&#19979;&#30340;objects</td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source"> * params</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source"> *	   Bucket: '', // &#38750;&#24517;&#20256;</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source"> *	   delimiter: '',</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> *	   'encoding-type': '',</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source"> *	   maker: '',</td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source"> *	   'max-keys': 0, // &#40664;&#35748;&#20026;1000 </td></tr><tr><td class="line">83</td><td class="hits"></td><td class="source"> *	   prefix: '',</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source"> *</td></tr><tr><td class="line">86</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">87</td><td class="hits">1</td><td class="source">function listObjects (params, cb) {</td></tr><tr class="hit"><td class="line">88</td><td class="hits">3</td><td class="source">	var queryString = [];</td></tr><tr class="hit"><td class="line">89</td><td class="hits">3</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="hit"><td class="line">90</td><td class="hits">1</td><td class="source">		cb = params;</td></tr><tr class="hit"><td class="line">91</td><td class="hits">1</td><td class="source">		params = {};</td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="hit"><td class="line">93</td><td class="hits">2</td><td class="source">		Object.keys(params).forEach(function(key) {</td></tr><tr class="hit"><td class="line">94</td><td class="hits">7</td><td class="source">			if(key !== 'Bucket') {</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source">				/**</td></tr><tr><td class="line">96</td><td class="hits"></td><td class="source">				 * &#22312;&#20043;&#21069;&#30340;&#36923;&#36753;&#20013;,&#21487;&#20197;&#20256;&#36882;&#20540;&#20026;&#31354;&#30340; delimiter</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">				 * &#20294;&#26159;&#29616;&#22312;&#21518;&#31471;&#20462;&#25913;&#36923;&#36753;&#20102;,&#31105;&#27490;&#20256;&#36882;&#36825;&#26679;&#30340;delimiter</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source">				 */</td></tr><tr class="hit"><td class="line">99</td><td class="hits">7</td><td class="source">				if(!(key == 'delimiter' &amp;&amp; params[key] =='')){</td></tr><tr class="hit"><td class="line">100</td><td class="hits">6</td><td class="source">					queryString.push(key + '=' + encodeURIComponent(params[key]));</td></tr><tr><td class="line">101</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">		});</td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">105</td><td class="hits">3</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">106</td><td class="hits">3</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">107</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">109</td><td class="hits">3</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">111</td><td class="hits">3</td><td class="source">	var resource = '/';</td></tr><tr><td class="line">112</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">113</td><td class="hits">3</td><td class="source">	var req = {</td></tr><tr><td class="line">114</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">116</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">117</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">119</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">120</td><td class="hits">3</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">121</td><td class="hits">3</td><td class="source">	var body = null;</td></tr><tr><td class="line">122</td><td class="hits"></td><td class="source">	// &#22914;&#26524;&#20256;&#20837;&#30340;params&#38500;&#20102;Bucket,&#36824;&#26377;&#20854;&#20182;&#30340;&#21017;&#65292;&#37325;&#26032;&#35774;&#32622;uri</td></tr><tr class="hit"><td class="line">123</td><td class="hits">3</td><td class="source">	if(queryString.length &gt; 0) {</td></tr><tr class="hit"><td class="line">124</td><td class="hits">2</td><td class="source">		req.uri += (req.uri.indexOf('?') &gt;= 0 ? '&amp;' : '?');</td></tr><tr class="hit"><td class="line">125</td><td class="hits">2</td><td class="source">		req.uri += queryString.join('&amp;');</td></tr><tr><td class="line">126</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">127</td><td class="hits">3</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">129</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source"> * &#33719;&#21462;bucket&#26435;&#38480;</td></tr><tr><td class="line">131</td><td class="hits"></td><td class="source"> * params</td></tr><tr><td class="line">132</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">133</td><td class="hits"></td><td class="source"> *	 Bucket: '' // &#38750;&#24517;&#20256;	</td></tr><tr><td class="line">134</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">135</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">136</td><td class="hits">1</td><td class="source">function getACL(params, cb) {</td></tr><tr class="hit"><td class="line">137</td><td class="hits">2</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="hit"><td class="line">138</td><td class="hits">2</td><td class="source">		cb = params;</td></tr><tr class="hit"><td class="line">139</td><td class="hits">2</td><td class="source">		params = {};</td></tr><tr><td class="line">140</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">141</td><td class="hits">2</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">143</td><td class="hits">2</td><td class="source">	var resource = '/?acl';</td></tr><tr class="hit"><td class="line">144</td><td class="hits">2</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">146</td><td class="hits">2</td><td class="source">	if(!bucketName) {</td></tr><tr class="hit"><td class="line">147</td><td class="hits">1</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">149</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">151</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">153</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">154</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">155</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">156</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">157</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">159</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">161</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">162</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source"> * &#20462;&#25913;bucket&#26435;&#38480;</td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source"> * params</td></tr><tr><td class="line">165</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">166</td><td class="hits"></td><td class="source"> * 	 Bucket: '' // &#38750;&#24517;&#39035;</td></tr><tr><td class="line">167</td><td class="hits"></td><td class="source"> *	 ACL: 'private || public-read || public-read-write || authenticated-read || bucket-owner-read || bucket-owner-full-control' // &#24517;&#39035;</td></tr><tr><td class="line">168</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">169</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">170</td><td class="hits">1</td><td class="source">function putACL(params, cb) {</td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">172</td><td class="hits">3</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr class="hit"><td class="line">173</td><td class="hits">3</td><td class="source">	var acl = params.ACL;</td></tr><tr class="hit"><td class="line">174</td><td class="hits">3</td><td class="source">	if (!acl) {</td></tr><tr class="hit"><td class="line">175</td><td class="hits">1</td><td class="source">		throw new Error('require the acl');</td></tr><tr><td class="line">176</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">178</td><td class="hits">2</td><td class="source">	if(util.verifyAcl(acl)==null){</td></tr><tr class="hit"><td class="line">179</td><td class="hits">1</td><td class="source">		throw new Error('the illegal acl');</td></tr><tr><td class="line">180</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">181</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">182</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">183</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">184</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">185</td><td class="hits">1</td><td class="source">	var resource = '/?acl';</td></tr><tr class="hit"><td class="line">186</td><td class="hits">1</td><td class="source">	var attr_Acl = 'x-'+config.prefix+'-acl';</td></tr><tr class="hit"><td class="line">187</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">188</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">189</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">190</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">191</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">192</td><td class="hits"></td><td class="source">		type: '',</td></tr><tr><td class="line">193</td><td class="hits"></td><td class="source">		headers:{}</td></tr><tr><td class="line">194</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">195</td><td class="hits">1</td><td class="source">	req.headers[attr_Acl] = acl;</td></tr><tr class="hit"><td class="line">196</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">197</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">198</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">199</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source"> * &#33719;&#21462;location</td></tr><tr><td class="line">202</td><td class="hits"></td><td class="source"> * params</td></tr><tr><td class="line">203</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source"> *    Bucket: '' // &#38750;&#24517;&#39035;</td></tr><tr><td class="line">205</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">206</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">207</td><td class="hits">1</td><td class="source">function getLocation(params, cb) {</td></tr><tr class="hit"><td class="line">208</td><td class="hits">1</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="hit"><td class="line">209</td><td class="hits">1</td><td class="source">		cb = params;</td></tr><tr class="hit"><td class="line">210</td><td class="hits">1</td><td class="source">		params = {};</td></tr><tr><td class="line">211</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">212</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">213</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">214</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">215</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">216</td><td class="hits">1</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr><td class="line">217</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">218</td><td class="hits">1</td><td class="source">	var resource = '/?location'</td></tr><tr><td class="line">219</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">220</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">222</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">223</td><td class="hits"></td><td class="source">		uri: config.protocol + '://'+bucketName+'.' + config.baseUrl + resource,</td></tr><tr><td class="line">224</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">225</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">226</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">227</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">228</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">230</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">231</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">232</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">233</td><td class="hits"></td><td class="source"> * &#33719;&#21462;&#26085;&#24535;&#20449;&#24687;</td></tr><tr><td class="line">234</td><td class="hits"></td><td class="source"> * params</td></tr><tr><td class="line">235</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">236</td><td class="hits"></td><td class="source"> *    Bucket: '' // &#38750;&#24517;&#39035;</td></tr><tr><td class="line">237</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">238</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">239</td><td class="hits">1</td><td class="source">function getLogging(params, cb) {</td></tr><tr class="hit"><td class="line">240</td><td class="hits">1</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="hit"><td class="line">241</td><td class="hits">1</td><td class="source">		cb = params;</td></tr><tr class="hit"><td class="line">242</td><td class="hits">1</td><td class="source">		params = {};</td></tr><tr><td class="line">243</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">244</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">245</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">246</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">247</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">248</td><td class="hits">1</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr><td class="line">249</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">250</td><td class="hits">1</td><td class="source">	var resource = '/?logging'</td></tr><tr><td class="line">251</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">252</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">253</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">254</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">255</td><td class="hits"></td><td class="source">		uri: config.protocol + '://'+bucketName+'.' + config.baseUrl + resource,</td></tr><tr><td class="line">256</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">257</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">258</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">259</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">260</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">262</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">263</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">264</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">265</td><td class="hits"></td><td class="source"> * &#26085;&#24535;&#20449;&#24687;&#35774;&#32622;</td></tr><tr><td class="line">266</td><td class="hits"></td><td class="source"> * @param {object} params&#65292;&#33509;&#20026;{BucketLoggingStatus:{}}&#65292;&#21017;&#26159;Disabling Log</td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">268</td><td class="hits"></td><td class="source"> *	 Bucket: '' // &#38750;&#24517;&#39035;	</td></tr><tr><td class="line">269</td><td class="hits"></td><td class="source"> *	 BucketLoggingStatus:{	// &#24517;&#39035;&#26377;&#65292;&#20294;&#21487;&#20197;&#20026;&#31354;&#20026;&#31354;&#30340;&#26102;&#20505;&#26159;&#21482;&#8220;&#31105;&#29992;&#26085;&#24535;&#8221;</td></tr><tr><td class="line">270</td><td class="hits"></td><td class="source"> *		LoggingEnabled&#65306; {}</td></tr><tr><td class="line">271</td><td class="hits"></td><td class="source"> *	 }  </td></tr><tr><td class="line">272</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">273</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">274</td><td class="hits">1</td><td class="source">function putLogging(params, cb) {</td></tr><tr class="miss"><td class="line">275</td><td class="hits">0</td><td class="source">	var BucketLoggingStatus = params.BucketLoggingStatus || null;</td></tr><tr class="miss"><td class="line">276</td><td class="hits">0</td><td class="source">	if(!BucketLoggingStatus) {</td></tr><tr class="miss"><td class="line">277</td><td class="hits">0</td><td class="source">		throw new Error('require the BucketLoggingStatus');</td></tr><tr><td class="line">278</td><td class="hits"></td><td class="source">	}</td></tr><tr class="miss"><td class="line">279</td><td class="hits">0</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr><td class="line">280</td><td class="hits"></td><td class="source"> </td></tr><tr class="miss"><td class="line">281</td><td class="hits">0</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">282</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">283</td><td class="hits"></td><td class="source">	}</td></tr><tr class="miss"><td class="line">284</td><td class="hits">0</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr class="miss"><td class="line">285</td><td class="hits">0</td><td class="source">	var resource = '/?logging'</td></tr><tr class="miss"><td class="line">286</td><td class="hits">0</td><td class="source">	var body = params;</td></tr><tr class="miss"><td class="line">287</td><td class="hits">0</td><td class="source">	var req = {</td></tr><tr><td class="line">288</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">289</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">290</td><td class="hits"></td><td class="source">		uri: config.protocol + '://'+bucketName+'.' + config.baseUrl + resource,</td></tr><tr><td class="line">291</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">292</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">293</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">294</td><td class="hits"></td><td class="source"> </td></tr><tr class="miss"><td class="line">295</td><td class="hits">0</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="miss"><td class="line">296</td><td class="hits">0</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">297</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">298</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">299</td><td class="hits"></td><td class="source"> * &#21024;&#38500;Bucket(&#21333;&#20010;)</td></tr><tr><td class="line">300</td><td class="hits"></td><td class="source"> * params </td></tr><tr><td class="line">301</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">302</td><td class="hits"></td><td class="source"> *	  Bucket: '' // &#38750;&#24517;&#20256;</td></tr><tr><td class="line">303</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">304</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">305</td><td class="hits">1</td><td class="source">function del(params, cb) {</td></tr><tr class="hit"><td class="line">306</td><td class="hits">1</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="hit"><td class="line">307</td><td class="hits">1</td><td class="source">		cb = params;</td></tr><tr class="hit"><td class="line">308</td><td class="hits">1</td><td class="source">		params = {};</td></tr><tr><td class="line">309</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">310</td><td class="hits">1</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr class="hit"><td class="line">311</td><td class="hits">1</td><td class="source">	var resource = '/'</td></tr><tr class="hit"><td class="line">312</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">313</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">314</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">315</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">316</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">317</td><td class="hits"></td><td class="source">		method: 'DELETE',</td></tr><tr><td class="line">318</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">319</td><td class="hits"></td><td class="source">		uri: config.protocol + '://'+bucketName+'.' + config.baseUrl + resource,</td></tr><tr><td class="line">320</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">321</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">322</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">323</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">324</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr><td class="line">325</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">326</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">327</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">328</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">329</td><td class="hits"></td><td class="source"> * &#26597;&#30475;&#26159;&#21542;&#26377;&#26435;&#38480;&#25805;&#20316;bucket</td></tr><tr><td class="line">330</td><td class="hits"></td><td class="source"> * params </td></tr><tr><td class="line">331</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">332</td><td class="hits"></td><td class="source"> *	  Bucket: '' // &#38750;&#24517;&#20256;</td></tr><tr><td class="line">333</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">334</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">335</td><td class="hits">1</td><td class="source">function headBucket(params, cb) {</td></tr><tr class="hit"><td class="line">336</td><td class="hits">1</td><td class="source">	if(typeof params === 'function') {</td></tr><tr class="miss"><td class="line">337</td><td class="hits">0</td><td class="source">		cb = params;</td></tr><tr class="miss"><td class="line">338</td><td class="hits">0</td><td class="source">		params = {};</td></tr><tr><td class="line">339</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">340</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">341</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">342</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">343</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">344</td><td class="hits">1</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr class="hit"><td class="line">345</td><td class="hits">1</td><td class="source">	var resource = '/';</td></tr><tr><td class="line">346</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">347</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">348</td><td class="hits"></td><td class="source">		method: 'HEAD',</td></tr><tr><td class="line">349</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">350</td><td class="hits"></td><td class="source">		uri: config.protocol + '://'+bucketName+'.' + config.baseUrl + resource,</td></tr><tr><td class="line">351</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">352</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">353</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">354</td><td class="hits">1</td><td class="source">	var curAuth = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">355</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">356</td><td class="hits">1</td><td class="source">	request(req, body, curAuth, cb);</td></tr><tr><td class="line">357</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">358</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">359</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">360</td><td class="hits"></td><td class="source">	put: put,</td></tr><tr><td class="line">361</td><td class="hits"></td><td class="source">	get: listObjects,</td></tr><tr><td class="line">362</td><td class="hits"></td><td class="source">	getACL: getACL,</td></tr><tr><td class="line">363</td><td class="hits"></td><td class="source">	putACL: putACL,</td></tr><tr><td class="line">364</td><td class="hits"></td><td class="source">	getLocation: getLocation,</td></tr><tr><td class="line">365</td><td class="hits"></td><td class="source">	getLogging: getLogging,</td></tr><tr><td class="line">366</td><td class="hits"></td><td class="source">	putLogging: putLogging, // 403</td></tr><tr><td class="line">367</td><td class="hits"></td><td class="source">	del: del,</td></tr><tr><td class="line">368</td><td class="hits"></td><td class="source">	head: headBucket,</td></tr><tr><td class="line">369</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">370</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="api/download.js">api/download.js</h2><div id="stats" class="high"><div class="percentage">87%</div><div class="sloc">96</div><div class="hits">84</div><div class="misses">12</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var config = require('../../config');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var async = require('async');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var crypto = require('crypto');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var path = require('path');</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">var util = require('../util');</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">var fs = require('fs');</td></tr><tr class="hit"><td class="line">7</td><td class="hits">1</td><td class="source">var nconf = require('nconf');</td></tr><tr class="hit"><td class="line">8</td><td class="hits">1</td><td class="source">var debug = require('debug')('download');</td></tr><tr class="hit"><td class="line">9</td><td class="hits">1</td><td class="source">var ProgressBar = require('progress');</td></tr><tr class="hit"><td class="line">10</td><td class="hits">1</td><td class="source">var bar, barDir;</td></tr><tr class="hit"><td class="line">11</td><td class="hits">1</td><td class="source">var cachePath = config.cachePath;</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> * &#33719;&#21462;&#21152;&#23494;&#21518;&#30340;&#25991;&#20214;&#21517;&#23383;</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">16</td><td class="hits">1</td><td class="source">var getFilename = function(filePath, len) {</td></tr><tr class="hit"><td class="line">17</td><td class="hits">2</td><td class="source">	var len = len || 16;</td></tr><tr class="hit"><td class="line">18</td><td class="hits">2</td><td class="source">	var hmac = crypto.createHmac('md5', 'KS3');</td></tr><tr class="hit"><td class="line">19</td><td class="hits">2</td><td class="source">	hmac.update(filePath);</td></tr><tr class="hit"><td class="line">20</td><td class="hits">2</td><td class="source">	var str = hmac.digest('base64');</td></tr><tr class="hit"><td class="line">21</td><td class="hits">2</td><td class="source">	return (new Buffer(str).toString('base64')) + '.cache'</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source"> * Bin: ks3 download -b $BUCKET -k $KEY -p $path</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> */</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">28</td><td class="hits">1</td><td class="source">function download(params, cb) {</td></tr><tr class="hit"><td class="line">29</td><td class="hits">2</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">	// &#36825;&#20010;&#22320;&#26041;&#19981;&#33021;&#36827;&#34892;encode</td></tr><tr class="hit"><td class="line">31</td><td class="hits">2</td><td class="source">	var key = params.Key || null;</td></tr><tr class="hit"><td class="line">32</td><td class="hits">2</td><td class="source">	var filePath = path.resolve(process.cwd(), params.filePath) || null;</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">34</td><td class="hits">2</td><td class="source">	if (!bucketName) {</td></tr><tr class="miss"><td class="line">35</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">38</td><td class="hits">2</td><td class="source">	if (!key) {</td></tr><tr class="miss"><td class="line">39</td><td class="hits">0</td><td class="source">		throw new Error('require the object Key');</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">41</td><td class="hits">2</td><td class="source">	if (!filePath) {</td></tr><tr class="miss"><td class="line">42</td><td class="hits">0</td><td class="source">		throw new Error('require the file path');</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">45</td><td class="hits">2</td><td class="source">	var self = this;</td></tr><tr class="hit"><td class="line">46</td><td class="hits">2</td><td class="source">	var ak = self.ak;</td></tr><tr class="hit"><td class="line">47</td><td class="hits">2</td><td class="source">	var sk = self.sk;</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">	// &#32531;&#23384;&#25991;&#20214;&#22320;&#22336;</td></tr><tr class="hit"><td class="line">50</td><td class="hits">2</td><td class="source">	var fileName = getFilename(filePath);</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">	// &#29992;&#25143;&#35201;&#19979;&#36733;&#29983;&#25104;&#30340;&#25991;&#20214;</td></tr><tr class="hit"><td class="line">52</td><td class="hits">2</td><td class="source">	var downFileName = filePath + '.download';</td></tr><tr class="hit"><td class="line">53</td><td class="hits">2</td><td class="source">	var configFile = path.join(cachePath, fileName);</td></tr><tr class="hit"><td class="line">54</td><td class="hits">2</td><td class="source">	nconf.file({</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">		file: configFile</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source">	});</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">	// &#20998;&#22359;&#22823;&#23567;</td></tr><tr class="hit"><td class="line">58</td><td class="hits">2</td><td class="source">	var chunk = params.chunk || 1 * 1024 * 10;</td></tr><tr class="hit"><td class="line">59</td><td class="hits">2</td><td class="source">	var count = 0;</td></tr><tr class="hit"><td class="line">60</td><td class="hits">2</td><td class="source">	var index = 0;</td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">62</td><td class="hits">2</td><td class="source">	async.auto({</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">		/**</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">		 * &#21021;&#22987;&#21270;&#25110;&#32773;&#35835;&#21462;configFile</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">		 * 1. &#33719;&#21462;&#25991;&#20214;&#22823;&#23567;</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source">		 * 2. &#24182;&#19988;&#26681;&#25454;&#20998;&#22359;&#22823;&#23567;&#35745;&#31639;&#20986;&#24635;&#20849;&#35831;&#27714;&#27425;&#25968;</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">		 */</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">		init: function(callback) {</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">			/**</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">			 * &#35774;&#32622;&#25110;&#35835;&#21462;&#22522;&#26412;&#25968;&#25454;</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source">			 */</td></tr><tr class="hit"><td class="line">72</td><td class="hits">2</td><td class="source">			if (fs.existsSync(configFile)) { // &#20043;&#21069;&#24050;&#32463;&#26377;&#37197;&#32622;&#20449;&#24687;&#20102;</td></tr><tr class="hit"><td class="line">73</td><td class="hits">1</td><td class="source">				chunk = nconf.get('chunk');</td></tr><tr class="hit"><td class="line">74</td><td class="hits">1</td><td class="source">				count = nconf.get('count');</td></tr><tr class="hit"><td class="line">75</td><td class="hits">1</td><td class="source">				index = nconf.get('index');</td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="hit"><td class="line">77</td><td class="hits">1</td><td class="source">				nconf.set('BUCKET', bucketName);</td></tr><tr class="hit"><td class="line">78</td><td class="hits">1</td><td class="source">				nconf.set('KEY', key);</td></tr><tr class="hit"><td class="line">79</td><td class="hits">1</td><td class="source">				nconf.set('path', filePath);</td></tr><tr class="hit"><td class="line">80</td><td class="hits">1</td><td class="source">				nconf.set('chunk',chunk);</td></tr><tr class="hit"><td class="line">81</td><td class="hits">1</td><td class="source">				nconf.set('count', 0);</td></tr><tr class="hit"><td class="line">82</td><td class="hits">1</td><td class="source">				nconf.set('index', 0);</td></tr><tr class="hit"><td class="line">83</td><td class="hits">1</td><td class="source">				nconf.save();</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source">				// &#22914;&#26524;&#24050;&#32463;&#23384;&#22312;&#37325;&#21517;&#19979;&#36733;&#25991;&#20214;,&#20808;&#21024;&#38500;&#20182;</td></tr><tr class="hit"><td class="line">85</td><td class="hits">1</td><td class="source">				if (fs.existsSync(downFileName)) {</td></tr><tr class="miss"><td class="line">86</td><td class="hits">0</td><td class="source">					fs.unlinkSync(downFileName);</td></tr><tr><td class="line">87</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">89</td><td class="hits"></td><td class="source">			/**</td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source">			 * &#33719;&#21462;&#25991;&#20214;&#20449;&#24687;</td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source">			 */</td></tr><tr class="hit"><td class="line">92</td><td class="hits">2</td><td class="source">			if (nconf.get('count') == 0) {</td></tr><tr class="hit"><td class="line">93</td><td class="hits">2</td><td class="source">				debug('&#36828;&#31243;&#33719;&#21462;&#20803;&#25968;&#25454;')</td></tr><tr class="hit"><td class="line">94</td><td class="hits">2</td><td class="source">				self.object.head(params, function(err, data, res) {</td></tr><tr class="hit"><td class="line">95</td><td class="hits">2</td><td class="source">					if (err) {</td></tr><tr class="hit"><td class="line">96</td><td class="hits">1</td><td class="source">						callback(err, data);</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">					} else {</td></tr><tr class="hit"><td class="line">98</td><td class="hits">1</td><td class="source">						var length = res.headers['content-length'];</td></tr><tr class="hit"><td class="line">99</td><td class="hits">1</td><td class="source">						count = parseInt(length / chunk) + (length % chunk== 0 ? 0: 1);</td></tr><tr><td class="line">100</td><td class="hits"></td><td class="source">						// &#21518;&#31471;&#36820;&#22238; &#25991;&#20214;&#22823;&#23567;&#20026;0</td></tr><tr class="hit"><td class="line">101</td><td class="hits">1</td><td class="source">						if (count == 0) {</td></tr><tr class="miss"><td class="line">102</td><td class="hits">0</td><td class="source">							callback({</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">								msg: '&#25991;&#20214;&#22823;&#23567;&#20026;0'</td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source">							})</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source">						} else {</td></tr><tr class="hit"><td class="line">106</td><td class="hits">1</td><td class="source">							nconf.set('count', count);</td></tr><tr class="hit"><td class="line">107</td><td class="hits">1</td><td class="source">							callback(null);</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source">					}</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source">				});</td></tr><tr><td class="line">111</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="miss"><td class="line">112</td><td class="hits">0</td><td class="source">				debug('&#26412;&#22320;&#35835;&#21462;&#25968;&#25454;')</td></tr><tr class="miss"><td class="line">113</td><td class="hits">0</td><td class="source">				count = nconf.get('count');</td></tr><tr class="miss"><td class="line">114</td><td class="hits">0</td><td class="source">				index = nconf.get('index');</td></tr><tr class="miss"><td class="line">115</td><td class="hits">0</td><td class="source">				callback(null);</td></tr><tr><td class="line">116</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">117</td><td class="hits"></td><td class="source">		},</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source">		/**</td></tr><tr><td class="line">119</td><td class="hits"></td><td class="source">		 * &#19979;&#36733;&#20998;&#22359;&#25968;&#25454;,&#24182;&#36861;&#21152;&#21040;&#25991;&#20214;&#26411;&#23614;</td></tr><tr><td class="line">120</td><td class="hits"></td><td class="source">		 */</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source">		down: ['init', function(callback, result) {</td></tr><tr><td class="line">122</td><td class="hits"></td><td class="source">			// &#19979;&#36733;&#36923;&#36753;</td></tr><tr class="hit"><td class="line">123</td><td class="hits">1</td><td class="source">			var fileName = (function() {</td></tr><tr class="hit"><td class="line">124</td><td class="hits">1</td><td class="source">				var s = filePath.split('/');</td></tr><tr class="hit"><td class="line">125</td><td class="hits">1</td><td class="source">				return s[s.length - 1];</td></tr><tr><td class="line">126</td><td class="hits"></td><td class="source">			})();</td></tr><tr class="hit"><td class="line">127</td><td class="hits">1</td><td class="source">			bar = new ProgressBar('&#19979;&#36733; ' + fileName + ' [:bar] :percent :current/:total ', {</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source">				total: count,</td></tr><tr><td class="line">129</td><td class="hits"></td><td class="source">				width:20</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source">			});</td></tr><tr class="hit"><td class="line">131</td><td class="hits">1</td><td class="source">			bar.curr = index;</td></tr><tr class="hit"><td class="line">132</td><td class="hits">1</td><td class="source">			var downHandler = function() {</td></tr><tr class="hit"><td class="line">133</td><td class="hits">72</td><td class="source">				if (index + 1 &gt; count) { // &#19979;&#36733;&#32467;&#26463;</td></tr><tr class="hit"><td class="line">134</td><td class="hits">1</td><td class="source">					debug('&#19979;&#36733;&#32467;&#26463;')</td></tr><tr class="hit"><td class="line">135</td><td class="hits">1</td><td class="source">					callback(null);</td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source">				} else { // &#36824;&#27809;&#19979;&#36733;&#23436;,&#32487;&#32493;&#36827;&#34892;&#19979;&#36733;</td></tr><tr class="hit"><td class="line">137</td><td class="hits">71</td><td class="source">					debug('&#36827;&#34892;&#19979;&#36733;:', index, '/', count);</td></tr><tr class="hit"><td class="line">138</td><td class="hits">71</td><td class="source">					self.object.get({</td></tr><tr><td class="line">139</td><td class="hits"></td><td class="source">						Key: key,</td></tr><tr><td class="line">140</td><td class="hits"></td><td class="source">						range: 'bytes=' + index * chunk + '-' + ((index + 1) * chunk - 1)</td></tr><tr><td class="line">141</td><td class="hits"></td><td class="source">					},</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source">					function(err, data, res, originData) {</td></tr><tr class="hit"><td class="line">143</td><td class="hits">71</td><td class="source">						if (err) {</td></tr><tr class="miss"><td class="line">144</td><td class="hits">0</td><td class="source">							callback(err, data);</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source">						} else {</td></tr><tr class="hit"><td class="line">146</td><td class="hits">71</td><td class="source">							fs.appendFileSync(downFileName, originData);</td></tr><tr class="hit"><td class="line">147</td><td class="hits">71</td><td class="source">							index = index + 1;</td></tr><tr class="hit"><td class="line">148</td><td class="hits">71</td><td class="source">							bar.tick();</td></tr><tr class="hit"><td class="line">149</td><td class="hits">71</td><td class="source">							nconf.set('index', index);</td></tr><tr class="hit"><td class="line">150</td><td class="hits">71</td><td class="source">							nconf.save();</td></tr><tr class="hit"><td class="line">151</td><td class="hits">71</td><td class="source">							downHandler();</td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">153</td><td class="hits"></td><td class="source">					});</td></tr><tr><td class="line">154</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">155</td><td class="hits"></td><td class="source">			};</td></tr><tr class="hit"><td class="line">156</td><td class="hits">1</td><td class="source">			downHandler();</td></tr><tr><td class="line">157</td><td class="hits"></td><td class="source">		}]</td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source">	},</td></tr><tr><td class="line">159</td><td class="hits"></td><td class="source">	function(err, results) {</td></tr><tr class="hit"><td class="line">160</td><td class="hits">2</td><td class="source">		if (err) {</td></tr><tr class="hit"><td class="line">161</td><td class="hits">1</td><td class="source">			if (cb) {</td></tr><tr class="hit"><td class="line">162</td><td class="hits">1</td><td class="source">				cb(err, results)</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="miss"><td class="line">164</td><td class="hits">0</td><td class="source">				fs.unlinkSync(configFile);</td></tr><tr class="miss"><td class="line">165</td><td class="hits">0</td><td class="source">				throw err;</td></tr><tr><td class="line">166</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">167</td><td class="hits"></td><td class="source">		} else {</td></tr><tr class="hit"><td class="line">168</td><td class="hits">1</td><td class="source">			fs.unlinkSync(configFile);</td></tr><tr class="hit"><td class="line">169</td><td class="hits">1</td><td class="source">			fs.renameSync(downFileName, filePath);</td></tr><tr class="hit"><td class="line">170</td><td class="hits">1</td><td class="source">			if (cb) {</td></tr><tr class="hit"><td class="line">171</td><td class="hits">1</td><td class="source">				cb(err, {msg:'success',path:filePath}, null);</td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">173</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">174</td><td class="hits"></td><td class="source">	})</td></tr><tr><td class="line">175</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">176</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">178</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">179</td><td class="hits"></td><td class="source">	start: download</td></tr><tr><td class="line">180</td><td class="hits"></td><td class="source">}</td></tr></tbody></table></div><div class="file"><h2 id="api/object.js">api/object.js</h2><div id="stats" class="high"><div class="percentage">85%</div><div class="sloc">190</div><div class="hits">162</div><div class="misses">28</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var request = require('./../request');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var auth = require('./../auth');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var config = require('./../../config');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var util = require('../util');</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">var mime = require('mime');</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">var fs = require('fs');</td></tr><tr class="hit"><td class="line">7</td><td class="hits">1</td><td class="source">var uploadMaxSize = config.uploadMaxSize;</td></tr><tr class="hit"><td class="line">8</td><td class="hits">1</td><td class="source">var CHUNK_MIN_SIZE = 5 * 1024 * 1024;</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> * &#21024;&#38500;&#21333;&#20010;Object</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source"> * params: {</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> *	  Bucket: '', // &#38750;&#24517;&#20256;</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source"> *    Key: '' // Object Key  &#24517;&#39035;&#20256;</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> *    VersionId: ''</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">17</td><td class="hits">1</td><td class="source">function del(params, cb) {</td></tr><tr class="hit"><td class="line">18</td><td class="hits">1</td><td class="source">	if (params.Key === null || params.Key === undefined) {</td></tr><tr class="miss"><td class="line">19</td><td class="hits">0</td><td class="source">		throw new Error('require the Key');</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">21</td><td class="hits">1</td><td class="source">	var key = util.encodeKey(params.Key);</td></tr><tr class="hit"><td class="line">22</td><td class="hits">1</td><td class="source">	var resource = params.VersionId ? '/' + key + '?versionId=' + params.VersionId: '/' + key;</td></tr><tr class="hit"><td class="line">23</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">24</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">25</td><td class="hits">0</td><td class="source">		throw new Error('require the bucket name');</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">27</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source">		method: 'DELETE',</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">35</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">36</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">37</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source"> * &#33719;&#21462;object</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source"> * params: {</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> *	  Bucket: '', //&#38750;&#24517;&#20256;</td></tr><tr><td class="line">45</td><td class="hits"></td><td class="source"> *    Key: '' // Object Key  &#24517;&#39035;&#20256;</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">48</td><td class="hits">1</td><td class="source">function get(params, cb) {</td></tr><tr class="hit"><td class="line">49</td><td class="hits">80</td><td class="source">	if (params.Key === null || params.Key === undefined) {</td></tr><tr class="hit"><td class="line">50</td><td class="hits">1</td><td class="source">		throw new Error('require the Key');</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">52</td><td class="hits">79</td><td class="source">	var resource = '/' + util.encodeKey(params.Key);</td></tr><tr class="hit"><td class="line">53</td><td class="hits">79</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">54</td><td class="hits">79</td><td class="source">	var range = params.range || '';</td></tr><tr class="hit"><td class="line">55</td><td class="hits">79</td><td class="source">	if(!bucketName) {</td></tr><tr class="hit"><td class="line">56</td><td class="hits">1</td><td class="source">		throw new Error('require the bucket name');</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">58</td><td class="hits">78</td><td class="source">	var req = {</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">60</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">	};</td></tr><tr class="hit"><td class="line">65</td><td class="hits">78</td><td class="source">	var reRange = /^bytes=(\d+)-(\d+)$/i;</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">67</td><td class="hits">78</td><td class="source">	if(range!==''&amp;&amp; reRange.test(range)){</td></tr><tr class="hit"><td class="line">68</td><td class="hits">71</td><td class="source">		req.headers['Range'] = range;</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">70</td><td class="hits">78</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">71</td><td class="hits">78</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">72</td><td class="hits">78</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source"> * &#33719;&#21462;Object ACL</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> * params: {</td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source"> *    Key: '' // Object Key  &#24517;&#39035;&#20256;</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">81</td><td class="hits">1</td><td class="source">function getAcl(params, cb) {</td></tr><tr class="hit"><td class="line">82</td><td class="hits">1</td><td class="source">	if (params.Key === null || params.Key === undefined) {</td></tr><tr class="miss"><td class="line">83</td><td class="hits">0</td><td class="source">		throw new Error('require the Key');</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">85</td><td class="hits">1</td><td class="source">	var key = util.encodeKey(params.Key);</td></tr><tr class="hit"><td class="line">86</td><td class="hits">1</td><td class="source">	var resource = params.VersionId ? '/' + key + '?ACL&amp;versionId=' + params.VersionId: '/' + key + '?acl';</td></tr><tr class="hit"><td class="line">87</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">88</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">89</td><td class="hits">0</td><td class="source">		throw new Error('require the bucket name');</td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">91</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">93</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">96</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">99</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">100</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">101</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source"> * &#35774;&#32622; Object ACL</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source"> * params {</td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source"> *    Key: '', // Object Key  &#24517;&#39035;&#20256;</td></tr><tr><td class="line">107</td><td class="hits"></td><td class="source"> *    VersionId: '',</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source"> *    ACL: ''  // Object ACL &#24517;&#39035;</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">111</td><td class="hits">1</td><td class="source">function putAcl(params, cb) {</td></tr><tr class="hit"><td class="line">112</td><td class="hits">1</td><td class="source">	var ACL = params.ACL;</td></tr><tr class="hit"><td class="line">113</td><td class="hits">1</td><td class="source">	if (params.Key === null || params.Key === undefined) {</td></tr><tr class="miss"><td class="line">114</td><td class="hits">0</td><td class="source">		throw new Error('require the Key');</td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">116</td><td class="hits">1</td><td class="source">	if (!ACL) {</td></tr><tr class="miss"><td class="line">117</td><td class="hits">0</td><td class="source">		throw new Error('require the permission');</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">119</td><td class="hits">1</td><td class="source">	if (util.verifyAcl(ACL) == null) {</td></tr><tr class="miss"><td class="line">120</td><td class="hits">0</td><td class="source">		throw new Error('the illegal ACL');</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">122</td><td class="hits">1</td><td class="source">	var key = util.encodeKey(params.Key);</td></tr><tr class="hit"><td class="line">123</td><td class="hits">1</td><td class="source">	var resource = params.VersionId ? '/' + key + '?ACL&amp;versionId=' + params.VersionId: '/' + key + '?acl';</td></tr><tr><td class="line">124</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">125</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">126</td><td class="hits">1</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">127</td><td class="hits">0</td><td class="source">		throw new Error('require the bucket name');</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">129</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">131</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">132</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">133</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">134</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">135</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">136</td><td class="hits">1</td><td class="source">	var attr_Acl = 'x-' + config.prefix + '-acl';</td></tr><tr class="hit"><td class="line">137</td><td class="hits">1</td><td class="source">	req.headers[attr_Acl] = ACL;</td></tr><tr class="hit"><td class="line">138</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">139</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">140</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">141</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source"> * &#33719;&#21462;&#25351;&#23450;object&#30340;&#20803;&#25968;&#25454;</td></tr><tr><td class="line">144</td><td class="hits"></td><td class="source"> * params {</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source"> *    Key: '' // &#24517;&#39035;</td></tr><tr><td class="line">146</td><td class="hits"></td><td class="source"> *    VersionId: ''</td></tr><tr><td class="line">147</td><td class="hits"></td><td class="source"> * }</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">149</td><td class="hits">1</td><td class="source">function headObject(params, cb) {</td></tr><tr class="hit"><td class="line">150</td><td class="hits">4</td><td class="source">	if (params.Key === null || params.Key === undefined) {</td></tr><tr class="miss"><td class="line">151</td><td class="hits">0</td><td class="source">		throw new Error('require the Key');</td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">153</td><td class="hits">4</td><td class="source">	var key = util.encodeKey(params.Key);</td></tr><tr class="hit"><td class="line">154</td><td class="hits">4</td><td class="source">	var resource = params.VersionId ? '/' + key + '?versionId=' + params.VersionId: '/' + key;</td></tr><tr class="hit"><td class="line">155</td><td class="hits">4</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">156</td><td class="hits">4</td><td class="source">	if(!bucketName) {</td></tr><tr class="miss"><td class="line">157</td><td class="hits">0</td><td class="source">		throw new Error('require the bucket name');</td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">159</td><td class="hits">4</td><td class="source">	var req = {</td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source">		method: 'HEAD',</td></tr><tr><td class="line">161</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">162</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source">		type: ''</td></tr><tr><td class="line">165</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">166</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">167</td><td class="hits">4</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">168</td><td class="hits">4</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">169</td><td class="hits">4</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">170</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">173</td><td class="hits">1</td><td class="source">function put(params, cb, headers) {</td></tr><tr class="hit"><td class="line">174</td><td class="hits">22</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';</td></tr><tr class="hit"><td class="line">175</td><td class="hits">22</td><td class="source">	var Key = util.encodeKey(params.Key) || null;</td></tr><tr class="hit"><td class="line">176</td><td class="hits">22</td><td class="source">	var filePath = params.filePath || null;</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">178</td><td class="hits">22</td><td class="source">	if (!bucketName) {</td></tr><tr class="miss"><td class="line">179</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">180</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">181</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">182</td><td class="hits">22</td><td class="source">	if (!Key) {</td></tr><tr class="miss"><td class="line">183</td><td class="hits">0</td><td class="source">		throw new Error('require the object Key');</td></tr><tr><td class="line">184</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">185</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">186</td><td class="hits">22</td><td class="source">	var ak = this.ak;</td></tr><tr class="hit"><td class="line">187</td><td class="hits">22</td><td class="source">	var sk = this.sk;</td></tr><tr class="hit"><td class="line">188</td><td class="hits">22</td><td class="source">	var body = '';</td></tr><tr><td class="line">189</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">190</td><td class="hits"></td><td class="source">	// &#20256;&#36882;&#30340;&#26159; STRING &#25110;&#32773;BUFFER</td></tr><tr class="hit"><td class="line">191</td><td class="hits">22</td><td class="source">	if (!filePath) {</td></tr><tr class="hit"><td class="line">192</td><td class="hits">8</td><td class="source">		body = params.Body || '';</td></tr><tr><td class="line">193</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">194</td><td class="hits"></td><td class="source">	} else { // &#20256;&#36882;&#30340;&#26159;&#25991;&#20214;&#36335;&#24452;</td></tr><tr class="hit"><td class="line">195</td><td class="hits">14</td><td class="source">		if (fs.existsSync(filePath) &amp;&amp; fs.statSync(filePath).isFile()) {</td></tr><tr class="hit"><td class="line">196</td><td class="hits">14</td><td class="source">			if (fs.statSync(filePath).size &gt;= uploadMaxSize) {</td></tr><tr class="miss"><td class="line">197</td><td class="hits">0</td><td class="source">				throw new Error('The file size should be less than 5G.Plase use `Multipart upload`, visit http://ks3.ksyun.com/doc/api/multipart_upload.html');</td></tr><tr><td class="line">198</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="hit"><td class="line">199</td><td class="hits">14</td><td class="source">				body = fs.readFileSync(filePath);</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source">		} else {</td></tr><tr class="miss"><td class="line">202</td><td class="hits">0</td><td class="source">			throw new Error('the file is illegal');</td></tr><tr><td class="line">203</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">205</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">206</td><td class="hits">22</td><td class="source">	var subResource = params.subResource;</td></tr><tr class="hit"><td class="line">207</td><td class="hits">22</td><td class="source">	var resource = '/' + Key + (subResource ? '?' + subResource : '');</td></tr><tr class="hit"><td class="line">208</td><td class="hits">22</td><td class="source">	var req = {</td></tr><tr><td class="line">209</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">210</td><td class="hits"></td><td class="source">		// &#22312;&#19978;&#20256;&#25991;&#20214;&#30340;&#26102;&#20505;&#40664;&#35748;&#19968;&#20010;content-type </td></tr><tr><td class="line">211</td><td class="hits"></td><td class="source">		type: params.isNoContent ?  '': require('mime').lookup(Key),</td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">214</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">215</td><td class="hits"></td><td class="source">		headers: headers || {}</td></tr><tr><td class="line">216</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">217</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">218</td><td class="hits">22</td><td class="source">	var acl = params.ACL;</td></tr><tr class="hit"><td class="line">219</td><td class="hits">22</td><td class="source">	if (acl &amp;&amp; util.verifyAcl(acl)) {</td></tr><tr class="hit"><td class="line">220</td><td class="hits">4</td><td class="source">		var attr_Acl = 'x-' + config.prefix + '-acl';</td></tr><tr class="hit"><td class="line">221</td><td class="hits">4</td><td class="source">		req.headers[attr_Acl] = params.ACL;</td></tr><tr><td class="line">222</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">223</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">224</td><td class="hits">22</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr><td class="line">225</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">226</td><td class="hits"></td><td class="source">	//console.log('req=========== :' + JSON.stringify(req));</td></tr><tr class="hit"><td class="line">227</td><td class="hits">22</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">228</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">230</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">231</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">232</td><td class="hits"></td><td class="source"> * &#19979;&#38754;&#36825;&#20123;&#37096;&#20998;&#37117;&#26159;&#20851;&#20110;&#20998;&#22359;&#19978;&#20256;&#30340;</td></tr><tr><td class="line">233</td><td class="hits"></td><td class="source"> */</td></tr><tr><td class="line">234</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">235</td><td class="hits"></td><td class="source"> * &#21021;&#22987;&#21270;</td></tr><tr><td class="line">236</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">237</td><td class="hits">1</td><td class="source">var multitpart_upload_init = function(params, cb) {</td></tr><tr class="hit"><td class="line">238</td><td class="hits">6</td><td class="source">	var ak = this.ak || '';</td></tr><tr class="hit"><td class="line">239</td><td class="hits">6</td><td class="source">	var sk = this.sk || '';</td></tr><tr class="hit"><td class="line">240</td><td class="hits">6</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">241</td><td class="hits">6</td><td class="source">	var Key = util.encodeKey(params.Key) || null;</td></tr><tr><td class="line">242</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">243</td><td class="hits">6</td><td class="source">	if (!bucketName) {</td></tr><tr class="miss"><td class="line">244</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">245</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">246</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">247</td><td class="hits">6</td><td class="source">	if (!Key) {</td></tr><tr class="miss"><td class="line">248</td><td class="hits">0</td><td class="source">		throw new Error('require the object Key');</td></tr><tr><td class="line">249</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">250</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">251</td><td class="hits">6</td><td class="source">	var body = null;</td></tr><tr class="hit"><td class="line">252</td><td class="hits">6</td><td class="source">	var resource = '/' + Key + '?uploads';</td></tr><tr class="hit"><td class="line">253</td><td class="hits">6</td><td class="source">	var req = {</td></tr><tr><td class="line">254</td><td class="hits"></td><td class="source">		method: 'POST',</td></tr><tr><td class="line">255</td><td class="hits"></td><td class="source">		// TODO: type:require('mime').lookup(key),</td></tr><tr><td class="line">256</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">257</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">258</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">259</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">260</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">262</td><td class="hits">6</td><td class="source">	var acl = params.ACL;</td></tr><tr class="hit"><td class="line">263</td><td class="hits">6</td><td class="source">	if (acl &amp;&amp; util.verifyAcl(acl)) {</td></tr><tr class="miss"><td class="line">264</td><td class="hits">0</td><td class="source">		var attr_Acl = 'x-' + config.prefix + '-acl';</td></tr><tr class="miss"><td class="line">265</td><td class="hits">0</td><td class="source">		req.headers[attr_Acl] = params.ACL;</td></tr><tr><td class="line">266</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">268</td><td class="hits"></td><td class="source">	// TODO: x-kss-meta</td></tr><tr class="hit"><td class="line">269</td><td class="hits">6</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr class="hit"><td class="line">270</td><td class="hits">6</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">271</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">272</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">273</td><td class="hits">1</td><td class="source">function upload_part(params, cb){</td></tr><tr class="hit"><td class="line">274</td><td class="hits">25</td><td class="source">	var ak = this.ak || '';</td></tr><tr class="hit"><td class="line">275</td><td class="hits">25</td><td class="source">	var sk = this.sk || '';</td></tr><tr class="hit"><td class="line">276</td><td class="hits">25</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">277</td><td class="hits">25</td><td class="source">	var key = util.encodeKey(params.Key)|| null;</td></tr><tr class="hit"><td class="line">278</td><td class="hits">25</td><td class="source">	var contentType = params.type || '';</td></tr><tr><td class="line">279</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">280</td><td class="hits">25</td><td class="source">	var partNumber = (typeof params.PartNumber!=='undefined') ?params.PartNumber: '';</td></tr><tr class="hit"><td class="line">281</td><td class="hits">25</td><td class="source">	var uploadId = params.UploadId || '';</td></tr><tr><td class="line">282</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">283</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">284</td><td class="hits">25</td><td class="source">	if (!bucketName || !key) {</td></tr><tr class="miss"><td class="line">285</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName and object key');</td></tr><tr><td class="line">286</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">287</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">288</td><td class="hits">25</td><td class="source">	if (partNumber==='' || !uploadId) {</td></tr><tr class="miss"><td class="line">289</td><td class="hits">0</td><td class="source">		throw new Error('require the partNumber and uploadId');</td></tr><tr><td class="line">290</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">291</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">292</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">293</td><td class="hits">25</td><td class="source">	var body = params.body || '';</td></tr><tr class="hit"><td class="line">294</td><td class="hits">25</td><td class="source">	var resource = '/' + key + '?partNumber='+partNumber+'&amp;uploadId='+uploadId;</td></tr><tr class="hit"><td class="line">295</td><td class="hits">25</td><td class="source">	var req = {</td></tr><tr><td class="line">296</td><td class="hits"></td><td class="source">		method: 'PUT',</td></tr><tr><td class="line">297</td><td class="hits"></td><td class="source">		type:contentType,</td></tr><tr><td class="line">298</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">299</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">300</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">301</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">302</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">303</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">304</td><td class="hits"></td><td class="source">	/**</td></tr><tr><td class="line">305</td><td class="hits"></td><td class="source">	 * TODO: encryption</td></tr><tr><td class="line">306</td><td class="hits"></td><td class="source">	/**/</td></tr><tr><td class="line">307</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">308</td><td class="hits">25</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr class="hit"><td class="line">309</td><td class="hits">25</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">310</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">311</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">312</td><td class="hits">1</td><td class="source">function upload_complete(params,cb){</td></tr><tr class="hit"><td class="line">313</td><td class="hits">2</td><td class="source">	var ak = this.ak || '';</td></tr><tr class="hit"><td class="line">314</td><td class="hits">2</td><td class="source">	var sk = this.sk || '';</td></tr><tr class="hit"><td class="line">315</td><td class="hits">2</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">316</td><td class="hits">2</td><td class="source">	var key = util.encodeKey(params.Key)|| null;</td></tr><tr><td class="line">317</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">318</td><td class="hits">2</td><td class="source">	var uploadId = params.UploadId || '';</td></tr><tr><td class="line">319</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">320</td><td class="hits">2</td><td class="source">	if (!bucketName || !key) {</td></tr><tr class="miss"><td class="line">321</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName and object key');</td></tr><tr><td class="line">322</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">323</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">324</td><td class="hits">2</td><td class="source">	if (!uploadId) {</td></tr><tr class="miss"><td class="line">325</td><td class="hits">0</td><td class="source">		throw new Error('require the uploadId');</td></tr><tr><td class="line">326</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">327</td><td class="hits"></td><td class="source">	/**</td></tr><tr><td class="line">328</td><td class="hits"></td><td class="source">	 * http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadComplete.html</td></tr><tr><td class="line">329</td><td class="hits"></td><td class="source">	 * &lt;CompleteMultipartUpload&gt;</td></tr><tr><td class="line">330</td><td class="hits"></td><td class="source">		&lt;Part&gt;</td></tr><tr><td class="line">331</td><td class="hits"></td><td class="source">		&lt;PartNumber&gt;PartNumber&lt;/PartNumber&gt;</td></tr><tr><td class="line">332</td><td class="hits"></td><td class="source">		&lt;ETag&gt;ETag&lt;/ETag&gt;</td></tr><tr><td class="line">333</td><td class="hits"></td><td class="source">		&lt;/Part&gt;</td></tr><tr><td class="line">334</td><td class="hits"></td><td class="source">		...</td></tr><tr><td class="line">335</td><td class="hits"></td><td class="source">	&lt;/CompleteMultipartUpload&gt;</td></tr><tr><td class="line">336</td><td class="hits"></td><td class="source">	*/</td></tr><tr class="hit"><td class="line">337</td><td class="hits">2</td><td class="source">	var body = params.body || '';</td></tr><tr class="hit"><td class="line">338</td><td class="hits">2</td><td class="source">	var resource = '/' + key + '?uploadId='+uploadId;</td></tr><tr class="hit"><td class="line">339</td><td class="hits">2</td><td class="source">	var req = {</td></tr><tr><td class="line">340</td><td class="hits"></td><td class="source">		method: 'POST',</td></tr><tr><td class="line">341</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">342</td><td class="hits"></td><td class="source">		type:'text/plain',</td></tr><tr><td class="line">343</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">344</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">345</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">346</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">347</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">348</td><td class="hits">2</td><td class="source">	var acl = params.ACL;</td></tr><tr class="hit"><td class="line">349</td><td class="hits">2</td><td class="source">	if (acl &amp;&amp; util.verifyAcl(acl)) {</td></tr><tr class="miss"><td class="line">350</td><td class="hits">0</td><td class="source">		var attr_Acl = 'x-' + config.prefix + '-acl';</td></tr><tr class="miss"><td class="line">351</td><td class="hits">0</td><td class="source">		req.headers[attr_Acl] = params.ACL;</td></tr><tr><td class="line">352</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">353</td><td class="hits">2</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr class="hit"><td class="line">354</td><td class="hits">2</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">355</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">356</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">357</td><td class="hits">1</td><td class="source">function upload_abort(params,cb){</td></tr><tr class="hit"><td class="line">358</td><td class="hits">1</td><td class="source">	var ak = this.ak || '';</td></tr><tr class="hit"><td class="line">359</td><td class="hits">1</td><td class="source">	var sk = this.sk || '';</td></tr><tr class="hit"><td class="line">360</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">361</td><td class="hits">1</td><td class="source">	var key = util.encodeKey(params.Key)|| null;</td></tr><tr><td class="line">362</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">363</td><td class="hits">1</td><td class="source">	var uploadId = params.UploadId || '';</td></tr><tr><td class="line">364</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">365</td><td class="hits">1</td><td class="source">	if (!bucketName || !key) {</td></tr><tr class="miss"><td class="line">366</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName and object key');</td></tr><tr><td class="line">367</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">368</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">369</td><td class="hits">1</td><td class="source">	if (!uploadId) {</td></tr><tr class="miss"><td class="line">370</td><td class="hits">0</td><td class="source">		throw new Error('require the uploadId');</td></tr><tr><td class="line">371</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">372</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">373</td><td class="hits">1</td><td class="source">	var body = params.body || '';</td></tr><tr class="hit"><td class="line">374</td><td class="hits">1</td><td class="source">	var resource = '/' + key + '?uploadId='+uploadId;</td></tr><tr class="hit"><td class="line">375</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">376</td><td class="hits"></td><td class="source">		method: 'DELETE',</td></tr><tr><td class="line">377</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">378</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">379</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">380</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">381</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">382</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">383</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr class="hit"><td class="line">384</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">385</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">386</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">387</td><td class="hits">1</td><td class="source">function upload_list_part(params,cb){</td></tr><tr class="hit"><td class="line">388</td><td class="hits">1</td><td class="source">	var ak = this.ak || '';</td></tr><tr class="hit"><td class="line">389</td><td class="hits">1</td><td class="source">	var sk = this.sk || '';</td></tr><tr class="hit"><td class="line">390</td><td class="hits">1</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">391</td><td class="hits">1</td><td class="source">	var key = util.encodeKey(params.Key)|| null;</td></tr><tr><td class="line">392</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">393</td><td class="hits">1</td><td class="source">	var uploadId = params.UploadId || '';</td></tr><tr><td class="line">394</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">395</td><td class="hits">1</td><td class="source">	if (!bucketName || !key) {</td></tr><tr class="miss"><td class="line">396</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName and object key');</td></tr><tr><td class="line">397</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">398</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">399</td><td class="hits">1</td><td class="source">	if (!uploadId) {</td></tr><tr class="miss"><td class="line">400</td><td class="hits">0</td><td class="source">		throw new Error('require the uploadId');</td></tr><tr><td class="line">401</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">402</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">403</td><td class="hits">1</td><td class="source">	var body = params.body || '';</td></tr><tr class="hit"><td class="line">404</td><td class="hits">1</td><td class="source">	var resource = '/' + key + '?uploadId='+uploadId;</td></tr><tr class="hit"><td class="line">405</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">406</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">407</td><td class="hits"></td><td class="source">		date: util.getDate(),</td></tr><tr><td class="line">408</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + bucketName + '.' + config.baseUrl + resource,</td></tr><tr><td class="line">409</td><td class="hits"></td><td class="source">		resource: '/' + bucketName + resource,</td></tr><tr><td class="line">410</td><td class="hits"></td><td class="source">		headers: {}</td></tr><tr><td class="line">411</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">412</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">413</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(ak, sk, req, body);</td></tr><tr class="hit"><td class="line">414</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">415</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">416</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">417</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">418</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">419</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">420</td><td class="hits"></td><td class="source">	del: del,</td></tr><tr><td class="line">421</td><td class="hits"></td><td class="source">	get: get,</td></tr><tr><td class="line">422</td><td class="hits"></td><td class="source">	put: put,</td></tr><tr><td class="line">423</td><td class="hits"></td><td class="source">	getAcl: getAcl,</td></tr><tr><td class="line">424</td><td class="hits"></td><td class="source">	putAcl: putAcl,</td></tr><tr><td class="line">425</td><td class="hits"></td><td class="source">	head: headObject,</td></tr><tr><td class="line">426</td><td class="hits"></td><td class="source">	multitpart_upload_init: multitpart_upload_init,</td></tr><tr><td class="line">427</td><td class="hits"></td><td class="source">	upload_part:upload_part,</td></tr><tr><td class="line">428</td><td class="hits"></td><td class="source">	upload_complete:upload_complete,</td></tr><tr><td class="line">429</td><td class="hits"></td><td class="source">	upload_abort:upload_abort,</td></tr><tr><td class="line">430</td><td class="hits"></td><td class="source">	upload_list_part:upload_list_part</td></tr><tr><td class="line">431</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">432</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="api/service.js">api/service.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">10</div><div class="hits">10</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var request = require('./../request');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var auth = require('./../auth');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var config = require('./../../config');</td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source"> * &#33719;&#21462;bucket&#21015;&#34920;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">8</td><td class="hits">1</td><td class="source">function get(cb) {</td></tr><tr class="hit"><td class="line">9</td><td class="hits">1</td><td class="source">	var date = (new Date()).toUTCString();</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">11</td><td class="hits">1</td><td class="source">	var req = {</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source">		method: 'GET',</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">		date: date,</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source">		uri: config.protocol + '://' + config.baseUrl,</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">		resource: '/'</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">17</td><td class="hits">1</td><td class="source">	var authStr = auth.generateAuth(this.ak, this.sk, req);</td></tr><tr class="hit"><td class="line">18</td><td class="hits">1</td><td class="source">	var body = null;</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">20</td><td class="hits">1</td><td class="source">	request(req, body, authStr, cb);</td></tr><tr><td class="line">21</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">22</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">	get: get,</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source">	listBucket:get</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="api/upload.js">api/upload.js</h2><div id="stats" class="high"><div class="percentage">86%</div><div class="sloc">217</div><div class="hits">188</div><div class="misses">29</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var config = require('../../config');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var async = require('async');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var crypto = require('crypto');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var path = require('path');</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">var util = require('../util');</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">var fs = require('fs');</td></tr><tr class="hit"><td class="line">7</td><td class="hits">1</td><td class="source">var nconf = require('nconf');</td></tr><tr class="hit"><td class="line">8</td><td class="hits">1</td><td class="source">var debug = require('debug')('upload');</td></tr><tr class="hit"><td class="line">9</td><td class="hits">1</td><td class="source">var ProgressBar = require('progress');</td></tr><tr class="hit"><td class="line">10</td><td class="hits">1</td><td class="source">var mime = require('mime');</td></tr><tr class="hit"><td class="line">11</td><td class="hits">1</td><td class="source">var bar, barDir;</td></tr><tr class="hit"><td class="line">12</td><td class="hits">1</td><td class="source">var cachePath = config.cachePath;</td></tr><tr class="hit"><td class="line">13</td><td class="hits">1</td><td class="source">var chunkSize = config.chunkSize;</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">15</td><td class="hits">1</td><td class="source">var uploadMaxSize = config.uploadMaxSize;</td></tr><tr class="hit"><td class="line">16</td><td class="hits">1</td><td class="source">var multipartUploadMinSize = 100 * 1024 * 1024; // 100 MB</td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source"> * &#33719;&#21462;&#21152;&#23494;&#21518;&#30340;&#25991;&#20214;&#21517;&#23383;</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">21</td><td class="hits">1</td><td class="source">var getFilename = function(filePath, len) {</td></tr><tr class="hit"><td class="line">22</td><td class="hits">5</td><td class="source">	var len = len || 16;</td></tr><tr class="hit"><td class="line">23</td><td class="hits">5</td><td class="source">	var hmac = crypto.createHmac('md5', 'KS3');</td></tr><tr class="hit"><td class="line">24</td><td class="hits">5</td><td class="source">	hmac.update(filePath);</td></tr><tr class="hit"><td class="line">25</td><td class="hits">5</td><td class="source">	var str = hmac.digest('base64');</td></tr><tr class="hit"><td class="line">26</td><td class="hits">5</td><td class="source">	return (new Buffer(str).toString('base64')) + '.cache'</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> * &#33719;&#21462;&#25351;&#23450;&#30340;&#25991;&#20214;&#20869;&#23481;</td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">32</td><td class="hits">1</td><td class="source">var getFileContent = function(filePath, chunkSize, start, cb) {</td></tr><tr class="hit"><td class="line">33</td><td class="hits">22</td><td class="source">	var start = start;</td></tr><tr class="hit"><td class="line">34</td><td class="hits">22</td><td class="source">	fs.open(filePath, 'r', function(err, fd) {</td></tr><tr class="hit"><td class="line">35</td><td class="hits">22</td><td class="source">		fs.fstat(fd, function(err, stat) {</td></tr><tr class="hit"><td class="line">36</td><td class="hits">22</td><td class="source">			debug('&#27491;&#22312;&#35835;&#21462;&#25991;&#20214;&#20869;&#23481;');</td></tr><tr class="hit"><td class="line">37</td><td class="hits">22</td><td class="source">			var bufferSize = stat.size;</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">39</td><td class="hits">22</td><td class="source">			var index = start / chunkSize;</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">41</td><td class="hits">22</td><td class="source">			if (start + chunkSize &gt; bufferSize) {</td></tr><tr class="hit"><td class="line">42</td><td class="hits">1</td><td class="source">				chunkSize = bufferSize - start;</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">44</td><td class="hits">22</td><td class="source">			var buffer = new Buffer(chunkSize)</td></tr><tr class="hit"><td class="line">45</td><td class="hits">22</td><td class="source">			debug('&#20998;&#22359;&#22823;&#23567;:', chunkSize);</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">47</td><td class="hits">22</td><td class="source">			fs.read(fd, buffer, 0, chunkSize, start, function(err, byteRead, buf) {</td></tr><tr class="hit"><td class="line">48</td><td class="hits">22</td><td class="source">				cb(buf)</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">			})</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">		})</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">	})</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source"> * &#25226;&#37197;&#32622;&#20449;&#24687;&#20889;&#21040;&#37197;&#32622;&#25991;&#20214;&#37324;,&#20316;&#20026;&#32531;&#23384;</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">57</td><td class="hits">1</td><td class="source">var configInit = function(filePath, configFile, cb) {</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">59</td><td class="hits">1</td><td class="source">	fs.open(filePath, 'r+', function(err, fd) {</td></tr><tr class="hit"><td class="line">60</td><td class="hits">1</td><td class="source">		if (err) throw err;</td></tr><tr class="hit"><td class="line">61</td><td class="hits">1</td><td class="source">		fs.fstat(fd, function(err, stat) {</td></tr><tr class="hit"><td class="line">62</td><td class="hits">1</td><td class="source">			if (err) throw err;</td></tr><tr class="hit"><td class="line">63</td><td class="hits">1</td><td class="source">			var fileSize = stat.size;</td></tr><tr class="hit"><td class="line">64</td><td class="hits">1</td><td class="source">			var count = parseInt(fileSize / chunkSize) + ((fileSize % chunkSize == 0 ? 0: 1));</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">66</td><td class="hits">1</td><td class="source">			if (count == 0) {</td></tr><tr class="miss"><td class="line">67</td><td class="hits">0</td><td class="source">				cb({</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">					msg: 'The file is empty.'</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">				})</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="hit"><td class="line">71</td><td class="hits">1</td><td class="source">				nconf.set('name', filePath);</td></tr><tr class="hit"><td class="line">72</td><td class="hits">1</td><td class="source">				nconf.set('size', fileSize);</td></tr><tr class="hit"><td class="line">73</td><td class="hits">1</td><td class="source">				nconf.set('chunkSize', chunkSize);</td></tr><tr class="hit"><td class="line">74</td><td class="hits">1</td><td class="source">				nconf.set('count', count);</td></tr><tr class="hit"><td class="line">75</td><td class="hits">1</td><td class="source">				nconf.set('index', 1);</td></tr><tr class="hit"><td class="line">76</td><td class="hits">1</td><td class="source">				nconf.set('etags', {});</td></tr><tr class="hit"><td class="line">77</td><td class="hits">1</td><td class="source">				nconf.set('retries', 0);</td></tr><tr class="hit"><td class="line">78</td><td class="hits">1</td><td class="source">				nconf.save(function(err) {</td></tr><tr class="hit"><td class="line">79</td><td class="hits">1</td><td class="source">					if (cb) cb(err);</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source">				})</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source">		})</td></tr><tr><td class="line">83</td><td class="hits"></td><td class="source">	})</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">86</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">87</td><td class="hits"></td><td class="source"> * &#29983;&#25104;&#21512;&#24182;&#20998;&#22359;&#19978;&#20256;&#20351;&#29992;&#30340;xml</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">89</td><td class="hits">1</td><td class="source">var generateCompleteXML = function(configFile) {</td></tr><tr class="hit"><td class="line">90</td><td class="hits">1</td><td class="source">	var content = JSON.parse(fs.readFileSync(configFile).toString());</td></tr><tr class="hit"><td class="line">91</td><td class="hits">1</td><td class="source">	var index = content.index;</td></tr><tr class="hit"><td class="line">92</td><td class="hits">1</td><td class="source">	var str = '';</td></tr><tr class="hit"><td class="line">93</td><td class="hits">1</td><td class="source">	if (index &gt; 0) {</td></tr><tr class="hit"><td class="line">94</td><td class="hits">1</td><td class="source">		str = '&lt;CompleteMultipartUpload&gt;';</td></tr><tr class="hit"><td class="line">95</td><td class="hits">1</td><td class="source">		for (var i = 1; i &lt;= index; i++) {</td></tr><tr class="hit"><td class="line">96</td><td class="hits">21</td><td class="source">			str += '&lt;Part&gt;&lt;PartNumber&gt;' + i + '&lt;/PartNumber&gt;&lt;ETag&gt;' + content.etags[i] + '&lt;/ETag&gt;&lt;/Part&gt;'</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">98</td><td class="hits">1</td><td class="source">		str += '&lt;/CompleteMultipartUpload&gt;';</td></tr><tr><td class="line">99</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">100</td><td class="hits">1</td><td class="source">	return str;</td></tr><tr><td class="line">101</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source"> * &#19978;&#20256;&#25509;&#21475;</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source"> * </td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source"> * params:</td></tr><tr><td class="line">107</td><td class="hits"></td><td class="source"> * . Bucket</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source"> * . Key</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source"> * . filePath</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source"> * . fileSetting &#19978;&#20256;&#25991;&#20214;&#22841;&#30340;&#26102;&#20505;&#20351;&#29992; {&#26159;&#21542;&#36941;&#21382;&#23376;&#25991;&#20214;&#22841;,isDeep:BOOLEAN,&#24573;&#30053;&#30340;&#31867;&#22411;&#25991;&#20214;&#25110;&#32773;&#25991;&#20214;&#22841; ignore:RegExp}</td></tr><tr><td class="line">111</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">112</td><td class="hits">1</td><td class="source">function upload(params, cb) {</td></tr><tr class="hit"><td class="line">113</td><td class="hits">5</td><td class="source">	var bucketName = params.Bucket || this.bucketName || '';;</td></tr><tr class="hit"><td class="line">114</td><td class="hits">5</td><td class="source">	var key = util.encodeKey(params.Key) || null;</td></tr><tr class="hit"><td class="line">115</td><td class="hits">5</td><td class="source">	var filePath = path.resolve(process.cwd(), params.filePath) || null;</td></tr><tr><td class="line">116</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">117</td><td class="hits">5</td><td class="source">	if (!bucketName) {</td></tr><tr class="miss"><td class="line">118</td><td class="hits">0</td><td class="source">		throw new Error('require the bucketName');</td></tr><tr><td class="line">119</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">120</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">121</td><td class="hits">5</td><td class="source">	if (!key) {</td></tr><tr class="miss"><td class="line">122</td><td class="hits">0</td><td class="source">		throw new Error('require the object Key');</td></tr><tr><td class="line">123</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">124</td><td class="hits">5</td><td class="source">	if (!filePath) {</td></tr><tr class="miss"><td class="line">125</td><td class="hits">0</td><td class="source">		throw new Error('require the file path');</td></tr><tr><td class="line">126</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">127</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">129</td><td class="hits">5</td><td class="source">	var self = this;</td></tr><tr class="hit"><td class="line">130</td><td class="hits">5</td><td class="source">	var ak = self.ak;</td></tr><tr class="hit"><td class="line">131</td><td class="hits">5</td><td class="source">	var sk = self.sk;</td></tr><tr><td class="line">132</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">133</td><td class="hits">5</td><td class="source">	var fileName = getFilename(filePath);</td></tr><tr class="hit"><td class="line">134</td><td class="hits">5</td><td class="source">	var configFile = path.join(cachePath, fileName);</td></tr><tr><td class="line">135</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source">	// &#22312;&#37325;&#26032;&#24320;&#22987;&#19968;&#20010;&#36827;&#31243;&#30340;&#26102;&#20505;,&#28165;&#31354;&#37325;&#35797;&#27425;&#25968;</td></tr><tr class="hit"><td class="line">137</td><td class="hits">5</td><td class="source">	nconf.set('retries', 0);</td></tr><tr><td class="line">138</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">139</td><td class="hits"></td><td class="source">	// &#22914;&#26524;&#26159;&#25991;&#20214;,&#30452;&#25509;&#36827;&#34892;&#19978;&#20256;</td></tr><tr><td class="line">140</td><td class="hits"></td><td class="source">	// &#36824;&#20250;&#26681;&#25454;&#25991;&#20214;&#22823;&#23567;,&#36827;&#34892;&#31616;&#21333;&#19978;&#20256;&#21644;&#20998;&#22359;&#19978;&#20256;</td></tr><tr class="hit"><td class="line">141</td><td class="hits">5</td><td class="source">	var stats = fs.statSync(filePath);</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">143</td><td class="hits">5</td><td class="source">	if (fs.existsSync(filePath) &amp;&amp; stats.isFile()) {</td></tr><tr class="hit"><td class="line">144</td><td class="hits">3</td><td class="source">		console.log('  &#24320;&#22987;&#19978;&#20256;&#25991;&#20214;: ' + filePath);</td></tr><tr class="hit"><td class="line">145</td><td class="hits">3</td><td class="source">		debug('  &#24320;&#22987;&#19978;&#20256;&#25991;&#20214;: ' + filePath);</td></tr><tr><td class="line">146</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">147</td><td class="hits">3</td><td class="source">		var fileSizeInBytes = stats[&quot;size&quot;];</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source">		//if(fileSizeInBytes &lt;= config.chunkSize) { //5M &#20197;&#19979;put&#19978;&#20256;</td></tr><tr class="hit"><td class="line">149</td><td class="hits">3</td><td class="source">		if(fileSizeInBytes &lt; multipartUploadMinSize) { //100 M &#20197;&#19979;put&#19978;&#20256;</td></tr><tr class="hit"><td class="line">150</td><td class="hits">2</td><td class="source">			debug('&#20351;&#29992;`&#31616;&#21333;&#19978;&#20256;` &#25991;&#20214;:' + filePath);</td></tr><tr class="hit"><td class="line">151</td><td class="hits">2</td><td class="source">			self.object.put({</td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source">					filePath: filePath,</td></tr><tr><td class="line">153</td><td class="hits"></td><td class="source">					Key: key,</td></tr><tr><td class="line">154</td><td class="hits"></td><td class="source">					ACL: params.ACL</td></tr><tr><td class="line">155</td><td class="hits"></td><td class="source">				},</td></tr><tr><td class="line">156</td><td class="hits"></td><td class="source">				function(err, data, res) {</td></tr><tr class="hit"><td class="line">157</td><td class="hits">2</td><td class="source">					if (cb) cb(err, data, res);</td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source">				})</td></tr><tr><td class="line">159</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source">		}else {  //&#20998;&#22359;&#19978;&#20256;</td></tr><tr class="hit"><td class="line">161</td><td class="hits">1</td><td class="source">			self.config({</td></tr><tr><td class="line">162</td><td class="hits"></td><td class="source">				dataType: 'json'</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">			});</td></tr><tr class="hit"><td class="line">164</td><td class="hits">1</td><td class="source">			nconf.file({</td></tr><tr><td class="line">165</td><td class="hits"></td><td class="source">				file: configFile</td></tr><tr><td class="line">166</td><td class="hits"></td><td class="source">			});</td></tr><tr class="hit"><td class="line">167</td><td class="hits">1</td><td class="source">			var contentType = require('mime').lookup(filePath) || '';</td></tr><tr><td class="line">168</td><td class="hits"></td><td class="source">			// &#20998;&#22359;&#19978;&#20256;</td></tr><tr class="hit"><td class="line">169</td><td class="hits">1</td><td class="source">			async.auto({</td></tr><tr><td class="line">170</td><td class="hits"></td><td class="source">					/**</td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source">					 * &#21021;&#22987;&#21270;&#37197;&#32622;&#25991;&#20214;,&#22914;&#26524;&#27809;&#26377;&#23601;&#26032;&#24314;&#19968;&#20010;</td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source">					 */</td></tr><tr><td class="line">173</td><td class="hits"></td><td class="source">					init: function(callback) {</td></tr><tr class="hit"><td class="line">174</td><td class="hits">1</td><td class="source">						if (!fs.existsSync(configFile)) {</td></tr><tr class="hit"><td class="line">175</td><td class="hits">1</td><td class="source">							configInit(filePath, configFile, function(err) {</td></tr><tr class="hit"><td class="line">176</td><td class="hits">1</td><td class="source">								callback(err);</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source">							})</td></tr><tr><td class="line">178</td><td class="hits"></td><td class="source">						} else {</td></tr><tr class="miss"><td class="line">179</td><td class="hits">0</td><td class="source">							callback(null);</td></tr><tr><td class="line">180</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">181</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">182</td><td class="hits"></td><td class="source">					},</td></tr><tr><td class="line">183</td><td class="hits"></td><td class="source">					show: ['init', function(callback) {</td></tr><tr class="hit"><td class="line">184</td><td class="hits">1</td><td class="source">						console.log('  &#24320;&#22987;&#19978;&#20256;&#25991;&#20214;: ' + filePath)</td></tr><tr class="hit"><td class="line">185</td><td class="hits">1</td><td class="source">						bar = new ProgressBar(' [:bar] :percent', {</td></tr><tr><td class="line">186</td><td class="hits"></td><td class="source">							total: nconf.get('count')</td></tr><tr><td class="line">187</td><td class="hits"></td><td class="source">						});</td></tr><tr class="hit"><td class="line">188</td><td class="hits">1</td><td class="source">						bar.curr = nconf.get('index');</td></tr><tr class="hit"><td class="line">189</td><td class="hits">1</td><td class="source">						bar.render();</td></tr><tr class="hit"><td class="line">190</td><td class="hits">1</td><td class="source">						callback(null)</td></tr><tr><td class="line">191</td><td class="hits"></td><td class="source">					}],</td></tr><tr><td class="line">192</td><td class="hits"></td><td class="source">					/**</td></tr><tr><td class="line">193</td><td class="hits"></td><td class="source">					 * &#33719;&#21462;uploadId,&#22914;&#26524;&#26377;&#23601;&#30452;&#25509;&#35835;&#21462;,&#27809;&#26377;&#23601;&#20174;&#26381;&#21153;&#22120;&#33719;&#21462;&#19968;&#20010;</td></tr><tr><td class="line">194</td><td class="hits"></td><td class="source">					 */</td></tr><tr><td class="line">195</td><td class="hits"></td><td class="source">					getUploadId: ['init', function(callback) {</td></tr><tr class="hit"><td class="line">196</td><td class="hits">1</td><td class="source">						var uploadId = nconf.get('uploadId');</td></tr><tr><td class="line">197</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">198</td><td class="hits">1</td><td class="source">						if ( !! uploadId) {</td></tr><tr class="miss"><td class="line">199</td><td class="hits">0</td><td class="source">							callback(null, uploadId)</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">						} else {</td></tr><tr class="hit"><td class="line">201</td><td class="hits">1</td><td class="source">							self.object.multitpart_upload_init(params, function(err, data, res) {</td></tr><tr class="hit"><td class="line">202</td><td class="hits">1</td><td class="source">								uploadId = data.InitiateMultipartUploadResult.UploadId;</td></tr><tr class="hit"><td class="line">203</td><td class="hits">1</td><td class="source">								nconf.set('uploadId', uploadId);</td></tr><tr class="hit"><td class="line">204</td><td class="hits">1</td><td class="source">								nconf.save();</td></tr><tr class="hit"><td class="line">205</td><td class="hits">1</td><td class="source">								callback(null, uploadId)</td></tr><tr><td class="line">206</td><td class="hits"></td><td class="source">							});</td></tr><tr><td class="line">207</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">208</td><td class="hits"></td><td class="source">					}],</td></tr><tr><td class="line">209</td><td class="hits"></td><td class="source">					/**</td></tr><tr><td class="line">210</td><td class="hits"></td><td class="source">					 * &#23545;&#25991;&#20214;&#36827;&#34892;&#19978;&#20256;</td></tr><tr><td class="line">211</td><td class="hits"></td><td class="source">					 * &#19978;&#20256;&#21518;&#35201;&#25226;&#20449;&#24687;&#20889;&#21040;&#26412;&#22320;&#32531;&#23384;&#37197;&#32622;&#25991;&#20214;&#20013;</td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source">					 * &#22914;&#26524;&#37117;&#19978;&#20256;&#23436;&#20102;,&#23601;&#25226;&#37197;&#32622;&#25991;&#20214;&#21024;&#38500;</td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source">					 * &#24182;&#36890;&#30693;&#26381;&#21153;&#22120;,&#21512;&#24182;&#20998;&#22359;&#25991;&#20214;</td></tr><tr><td class="line">214</td><td class="hits"></td><td class="source">					 */</td></tr><tr><td class="line">215</td><td class="hits"></td><td class="source">					upload: ['getUploadId', function(callback, result) {</td></tr><tr class="hit"><td class="line">216</td><td class="hits">1</td><td class="source">						var uploadId = result.getUploadId;</td></tr><tr class="hit"><td class="line">217</td><td class="hits">1</td><td class="source">						var count = nconf.get('count');</td></tr><tr class="hit"><td class="line">218</td><td class="hits">1</td><td class="source">						var index = nconf.get('index');</td></tr><tr class="hit"><td class="line">219</td><td class="hits">1</td><td class="source">						var chunkSize = nconf.get('chunkSize');</td></tr><tr class="hit"><td class="line">220</td><td class="hits">1</td><td class="source">						var currentRetries = nconf.get('retries');</td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">222</td><td class="hits"></td><td class="source">						// &#22312;&#25253;&#38169;&#30340;&#26102;&#20505;&#37325;&#35797;</td></tr><tr class="hit"><td class="line">223</td><td class="hits">1</td><td class="source">						function retry(err) {</td></tr><tr class="hit"><td class="line">224</td><td class="hits">1</td><td class="source">							debug('upload ERROR:', err);</td></tr><tr class="hit"><td class="line">225</td><td class="hits">1</td><td class="source">							if (currentRetries &gt; config.retries) {</td></tr><tr class="miss"><td class="line">226</td><td class="hits">0</td><td class="source">								throw err</td></tr><tr><td class="line">227</td><td class="hits"></td><td class="source">							} else {</td></tr><tr class="hit"><td class="line">228</td><td class="hits">1</td><td class="source">								currentRetries = currentRetries + 1;</td></tr><tr class="hit"><td class="line">229</td><td class="hits">1</td><td class="source">								nconf.set('retries', currentRetries)</td></tr><tr class="hit"><td class="line">230</td><td class="hits">1</td><td class="source">								nconf.save();</td></tr><tr class="hit"><td class="line">231</td><td class="hits">1</td><td class="source">								console.log('&#31532; ' + currentRetries + ' &#27425;&#37325;&#35797;');</td></tr><tr class="hit"><td class="line">232</td><td class="hits">1</td><td class="source">								up();</td></tr><tr><td class="line">233</td><td class="hits"></td><td class="source">							}</td></tr><tr><td class="line">234</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">235</td><td class="hits"></td><td class="source">						// &#30495;&#27491;&#24448;&#26381;&#21153;&#31471;&#20256;&#36882;&#25968;&#25454;</td></tr><tr class="hit"><td class="line">236</td><td class="hits">1</td><td class="source">						function up() {</td></tr><tr class="hit"><td class="line">237</td><td class="hits">23</td><td class="source">							debug('&#19978;&#20256;&#29992;&#26102;', 'index: ' + index)</td></tr><tr class="hit"><td class="line">238</td><td class="hits">23</td><td class="source">							var start = (index - 1) * chunkSize;</td></tr><tr><td class="line">239</td><td class="hits"></td><td class="source">							// &#21028;&#26029;&#26159;&#21542;&#24050;&#32463;&#20840;&#37096;&#37117;&#20256;&#23436;&#20102;</td></tr><tr class="hit"><td class="line">240</td><td class="hits">23</td><td class="source">							if (index &lt;= count) {</td></tr><tr class="hit"><td class="line">241</td><td class="hits">22</td><td class="source">								getFileContent(filePath, chunkSize, start, function(body) {</td></tr><tr class="hit"><td class="line">242</td><td class="hits">22</td><td class="source">									delete params.filePath;</td></tr><tr class="hit"><td class="line">243</td><td class="hits">22</td><td class="source">									params.UploadId = uploadId;</td></tr><tr class="hit"><td class="line">244</td><td class="hits">22</td><td class="source">									params.PartNumber = index;</td></tr><tr class="hit"><td class="line">245</td><td class="hits">22</td><td class="source">									params.body = body;</td></tr><tr class="hit"><td class="line">246</td><td class="hits">22</td><td class="source">									params.type = contentType;</td></tr><tr class="hit"><td class="line">247</td><td class="hits">22</td><td class="source">									debug('&#27491;&#22312;&#19978;&#20256;&#31532; ', index, ' &#22359;,&#24635;&#20849;: ', + count + ' &#22359;');</td></tr><tr><td class="line">248</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">249</td><td class="hits">22</td><td class="source">									try {</td></tr><tr class="hit"><td class="line">250</td><td class="hits">22</td><td class="source">										self.object.upload_part(params, function(err, data, res) {</td></tr><tr class="hit"><td class="line">251</td><td class="hits">22</td><td class="source">											if (err) {</td></tr><tr class="hit"><td class="line">252</td><td class="hits">1</td><td class="source">												retry(err);</td></tr><tr><td class="line">253</td><td class="hits"></td><td class="source">											} else {</td></tr><tr class="hit"><td class="line">254</td><td class="hits">21</td><td class="source">												bar.tick();</td></tr><tr class="hit"><td class="line">255</td><td class="hits">21</td><td class="source">												var etag = res.headers.etag;</td></tr><tr class="hit"><td class="line">256</td><td class="hits">21</td><td class="source">												nconf.set('index', index);</td></tr><tr class="hit"><td class="line">257</td><td class="hits">21</td><td class="source">												nconf.set('etags:' + index, etag);</td></tr><tr class="hit"><td class="line">258</td><td class="hits">21</td><td class="source">												nconf.save(function(err) {</td></tr><tr class="hit"><td class="line">259</td><td class="hits">21</td><td class="source">													if (err) throw err;</td></tr><tr class="hit"><td class="line">260</td><td class="hits">21</td><td class="source">													index = index + 1;</td></tr><tr class="hit"><td class="line">261</td><td class="hits">21</td><td class="source">													up();</td></tr><tr><td class="line">262</td><td class="hits"></td><td class="source">												});</td></tr><tr><td class="line">263</td><td class="hits"></td><td class="source">											}</td></tr><tr><td class="line">264</td><td class="hits"></td><td class="source">										});</td></tr><tr><td class="line">265</td><td class="hits"></td><td class="source">									} catch(e) {</td></tr><tr class="miss"><td class="line">266</td><td class="hits">0</td><td class="source">										retry(e);</td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source">									}</td></tr><tr><td class="line">268</td><td class="hits"></td><td class="source">								})</td></tr><tr><td class="line">269</td><td class="hits"></td><td class="source">							} else {</td></tr><tr class="hit"><td class="line">270</td><td class="hits">1</td><td class="source">								debug('&#21457;&#36865;&#21512;&#24182;&#35831;&#27714;');</td></tr><tr class="hit"><td class="line">271</td><td class="hits">1</td><td class="source">								delete params.filePath;</td></tr><tr class="hit"><td class="line">272</td><td class="hits">1</td><td class="source">								params.UploadId = uploadId;</td></tr><tr class="hit"><td class="line">273</td><td class="hits">1</td><td class="source">								params.body = generateCompleteXML(configFile);</td></tr><tr><td class="line">274</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">275</td><td class="hits">1</td><td class="source">								self.object.upload_complete(params, function(err, data, res) {</td></tr><tr class="hit"><td class="line">276</td><td class="hits">1</td><td class="source">									if (err) throw err;</td></tr><tr class="hit"><td class="line">277</td><td class="hits">1</td><td class="source">									callback(err, data, res);</td></tr><tr><td class="line">278</td><td class="hits"></td><td class="source">								})</td></tr><tr><td class="line">279</td><td class="hits"></td><td class="source">							}</td></tr><tr><td class="line">280</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">281</td><td class="hits">1</td><td class="source">						};</td></tr><tr class="hit"><td class="line">282</td><td class="hits">1</td><td class="source">						up();</td></tr><tr><td class="line">283</td><td class="hits"></td><td class="source">					}]</td></tr><tr><td class="line">284</td><td class="hits"></td><td class="source">				},</td></tr><tr><td class="line">285</td><td class="hits"></td><td class="source">				function(err, results) {</td></tr><tr class="hit"><td class="line">286</td><td class="hits">1</td><td class="source">					if (err) throw err;</td></tr><tr><td class="line">287</td><td class="hits"></td><td class="source">					//&#21024;&#38500;&#37197;&#32622;</td></tr><tr class="hit"><td class="line">288</td><td class="hits">1</td><td class="source">					fs.unlinkSync(configFile);</td></tr><tr class="hit"><td class="line">289</td><td class="hits">1</td><td class="source">					if (cb) {</td></tr><tr class="hit"><td class="line">290</td><td class="hits">1</td><td class="source">						cb(err, results.upload[0], results.upload[1]);</td></tr><tr><td class="line">291</td><td class="hits"></td><td class="source">					}</td></tr><tr><td class="line">292</td><td class="hits"></td><td class="source">				});</td></tr><tr><td class="line">293</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">294</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">295</td><td class="hits">2</td><td class="source">	} else if (fs.existsSync(filePath) &amp;&amp; stats.isDirectory()) { // &#25991;&#20214;&#22841;&#19978;&#20256;</td></tr><tr class="hit"><td class="line">296</td><td class="hits">2</td><td class="source">		var fileList = util.walkFile(filePath, params.fileSetting);</td></tr><tr class="hit"><td class="line">297</td><td class="hits">2</td><td class="source">		nconf.file({</td></tr><tr><td class="line">298</td><td class="hits"></td><td class="source">			file: configFile</td></tr><tr><td class="line">299</td><td class="hits"></td><td class="source">		});</td></tr><tr class="hit"><td class="line">300</td><td class="hits">2</td><td class="source">		var count = fileList.length;</td></tr><tr class="hit"><td class="line">301</td><td class="hits">2</td><td class="source">		console.log('  &#24320;&#22987;&#19978;&#20256;&#25991;&#20214;&#22841;:' + filePath);</td></tr><tr class="hit"><td class="line">302</td><td class="hits">2</td><td class="source">		barDir = new ProgressBar('  ' + ' [:bar] :percent ', {</td></tr><tr><td class="line">303</td><td class="hits"></td><td class="source">			total: count,</td></tr><tr><td class="line">304</td><td class="hits"></td><td class="source">			width: 100</td></tr><tr><td class="line">305</td><td class="hits"></td><td class="source">		});</td></tr><tr class="hit"><td class="line">306</td><td class="hits">2</td><td class="source">		barDir.tick();</td></tr><tr class="hit"><td class="line">307</td><td class="hits">2</td><td class="source">		var index = 1;</td></tr><tr class="hit"><td class="line">308</td><td class="hits">2</td><td class="source">		if (count &gt; 0) {</td></tr><tr><td class="line">309</td><td class="hits"></td><td class="source">			// &#20808;&#21021;&#22987;&#21270;&#32531;&#23384;&#25991;&#20214;</td></tr><tr class="hit"><td class="line">310</td><td class="hits">2</td><td class="source">			if (!fs.existsSync(configFile)) {</td></tr><tr class="hit"><td class="line">311</td><td class="hits">2</td><td class="source">				nconf.set('name', filePath);</td></tr><tr><td class="line">312</td><td class="hits"></td><td class="source">				/**</td></tr><tr><td class="line">313</td><td class="hits"></td><td class="source">				 * &#32531;&#23384;&#20013;&#19981;&#35760;&#24405;&#25991;&#20214;&#20010;&#25968;&#21644;&#23436;&#25104;&#25968;</td></tr><tr><td class="line">314</td><td class="hits"></td><td class="source">				 * &#26159;&#22240;&#20026;&#22914;&#26524;&#20013;&#38388;&#26377;&#25991;&#20214;&#25913;&#21160;,&#20250;&#22686;&#21152;&#22797;&#26434;&#24230;</td></tr><tr><td class="line">315</td><td class="hits"></td><td class="source">				 * &#29616;&#22312;&#21482;&#38656;&#35201;&#21028;&#26029;&#29992;&#25143;&#19978;&#20256;&#30340;&#36825;&#20010;&#25991;&#20214;&#20043;&#21069;&#26377;&#27809;&#26377;&#19978;&#20256;&#36807;&#23601;&#22909;&#20102;</td></tr><tr><td class="line">316</td><td class="hits"></td><td class="source">				nconf.set('count',count);</td></tr><tr><td class="line">317</td><td class="hits"></td><td class="source">				nconf.set('index',index);</td></tr><tr><td class="line">318</td><td class="hits"></td><td class="source">				/**/</td></tr><tr class="hit"><td class="line">319</td><td class="hits">2</td><td class="source">				nconf.save();</td></tr><tr><td class="line">320</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">321</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">322</td><td class="hits">2</td><td class="source">			async.eachSeries(fileList, function(file, callback) {</td></tr><tr><td class="line">323</td><td class="hits"></td><td class="source">				// &#38656;&#35201;&#21435;&#25481;&#36335;&#24452;,&#21462;&#24471;&#30495;&#27491;&#25991;&#20214;&#21517;</td></tr><tr class="hit"><td class="line">324</td><td class="hits">10</td><td class="source">				var key2 = key + file.replace(filePath, '');</td></tr><tr><td class="line">325</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">326</td><td class="hits">10</td><td class="source">				if (!nconf.get('list:' + key2)) { // &#20043;&#21069;&#27809;&#26377;&#19978;&#20256;&#36807;&#36825;&#20010;&#25991;&#20214;</td></tr><tr class="hit"><td class="line">327</td><td class="hits">10</td><td class="source">					if (fs.statSync(file).isFile()) { // &#30896;&#21040;&#25991;&#20214;</td></tr><tr class="hit"><td class="line">328</td><td class="hits">7</td><td class="source">						if (fs.statSync(file).size &gt;= multipartUploadMinSize) { // &#22823;&#25991;&#20214;,&#22797;&#26434;&#19978;&#20256;</td></tr><tr class="miss"><td class="line">329</td><td class="hits">0</td><td class="source">							debug('&#20351;&#29992;`&#20998;&#22359;&#19978;&#20256;`,&#27491;&#22312;&#19978;&#20256;&#31532; ' + index + '/' + count + ' &#20010;&#25991;&#20214;:' + file);</td></tr><tr class="miss"><td class="line">330</td><td class="hits">0</td><td class="source">							self.upload.start({</td></tr><tr><td class="line">331</td><td class="hits"></td><td class="source">								filePath: file,</td></tr><tr><td class="line">332</td><td class="hits"></td><td class="source">								Key: key2</td></tr><tr><td class="line">333</td><td class="hits"></td><td class="source">							},</td></tr><tr><td class="line">334</td><td class="hits"></td><td class="source">							function(err, data, res) {</td></tr><tr class="miss"><td class="line">335</td><td class="hits">0</td><td class="source">								index = index + 1;</td></tr><tr class="miss"><td class="line">336</td><td class="hits">0</td><td class="source">								barDir.tick();</td></tr><tr class="miss"><td class="line">337</td><td class="hits">0</td><td class="source">								if (index &gt; count) {</td></tr><tr><td class="line">338</td><td class="hits"></td><td class="source">									// &#21024;&#38500;&#32531;&#23384;&#25991;&#20214;</td></tr><tr class="miss"><td class="line">339</td><td class="hits">0</td><td class="source">									fs.unlinkSync(configFile);</td></tr><tr class="miss"><td class="line">340</td><td class="hits">0</td><td class="source">									if (cb) cb(err, data, res);</td></tr><tr><td class="line">341</td><td class="hits"></td><td class="source">								} else {</td></tr><tr class="miss"><td class="line">342</td><td class="hits">0</td><td class="source">									nconf.set('list:' + key2, true);</td></tr><tr class="miss"><td class="line">343</td><td class="hits">0</td><td class="source">									nconf.save()</td></tr><tr class="miss"><td class="line">344</td><td class="hits">0</td><td class="source">									callback();</td></tr><tr><td class="line">345</td><td class="hits"></td><td class="source">								}</td></tr><tr><td class="line">346</td><td class="hits"></td><td class="source">							})</td></tr><tr><td class="line">347</td><td class="hits"></td><td class="source">						} else { // &#23567;&#25991;&#20214; &#31616;&#21333;&#19978;&#20256;</td></tr><tr><td class="line">348</td><td class="hits"></td><td class="source">							//debug('\n&#27491;&#22312;&#19978;&#20256;&#25991;&#20214;: ', file);</td></tr><tr class="hit"><td class="line">349</td><td class="hits">7</td><td class="source">							debug('&#20351;&#29992;`&#31616;&#21333;&#19978;&#20256;` &#25991;&#20214;:' + file);</td></tr><tr class="hit"><td class="line">350</td><td class="hits">7</td><td class="source">							self.object.put({</td></tr><tr><td class="line">351</td><td class="hits"></td><td class="source">								filePath: file,</td></tr><tr><td class="line">352</td><td class="hits"></td><td class="source">								Key: key2,</td></tr><tr><td class="line">353</td><td class="hits"></td><td class="source">								ACL: params.ACL</td></tr><tr><td class="line">354</td><td class="hits"></td><td class="source">							},</td></tr><tr><td class="line">355</td><td class="hits"></td><td class="source">							function(err, data, res) {</td></tr><tr class="hit"><td class="line">356</td><td class="hits">7</td><td class="source">								debug('index:', index, 'count:', count)</td></tr><tr class="hit"><td class="line">357</td><td class="hits">7</td><td class="source">								if (index &gt;= count) {</td></tr><tr class="hit"><td class="line">358</td><td class="hits">1</td><td class="source">									fs.unlinkSync(configFile);</td></tr><tr class="hit"><td class="line">359</td><td class="hits">1</td><td class="source">									if (cb) cb(err, data, res);</td></tr><tr><td class="line">360</td><td class="hits"></td><td class="source">								} else {</td></tr><tr class="hit"><td class="line">361</td><td class="hits">6</td><td class="source">									index = index + 1;</td></tr><tr class="hit"><td class="line">362</td><td class="hits">6</td><td class="source">									barDir.tick();</td></tr><tr class="hit"><td class="line">363</td><td class="hits">6</td><td class="source">									nconf.set('list:' + key2, true);</td></tr><tr class="hit"><td class="line">364</td><td class="hits">6</td><td class="source">									nconf.save()</td></tr><tr class="hit"><td class="line">365</td><td class="hits">6</td><td class="source">									callback();</td></tr><tr><td class="line">366</td><td class="hits"></td><td class="source">								}</td></tr><tr><td class="line">367</td><td class="hits"></td><td class="source">							})</td></tr><tr><td class="line">368</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">369</td><td class="hits"></td><td class="source">					} else { // &#25991;&#20214;&#22841;</td></tr><tr class="hit"><td class="line">370</td><td class="hits">3</td><td class="source">						if (index &gt;= count) {</td></tr><tr><td class="line">371</td><td class="hits"></td><td class="source">							// &#32479;&#19968;&#22238;&#35843;,&#25152;&#20197;&#27169;&#25311;&#19968;&#20010;&#36820;&#22238;&#29366;&#24577;</td></tr><tr class="hit"><td class="line">372</td><td class="hits">1</td><td class="source">							fs.unlinkSync(configFile);</td></tr><tr class="hit"><td class="line">373</td><td class="hits">1</td><td class="source">							if (cb) cb(null, null, {</td></tr><tr><td class="line">374</td><td class="hits"></td><td class="source">								statusCode: 200</td></tr><tr><td class="line">375</td><td class="hits"></td><td class="source">							});</td></tr><tr><td class="line">376</td><td class="hits"></td><td class="source">						} else {</td></tr><tr class="hit"><td class="line">377</td><td class="hits">2</td><td class="source">							index = index + 1;</td></tr><tr class="hit"><td class="line">378</td><td class="hits">2</td><td class="source">							nconf.set('list:' + key2, true);</td></tr><tr class="hit"><td class="line">379</td><td class="hits">2</td><td class="source">							nconf.save()</td></tr><tr class="hit"><td class="line">380</td><td class="hits">2</td><td class="source">							barDir.tick();</td></tr><tr class="hit"><td class="line">381</td><td class="hits">2</td><td class="source">							callback();</td></tr><tr><td class="line">382</td><td class="hits"></td><td class="source">						}</td></tr><tr><td class="line">383</td><td class="hits"></td><td class="source">					}</td></tr><tr><td class="line">384</td><td class="hits"></td><td class="source">				} else { // &#20043;&#21069;&#24050;&#32463;&#19978;&#20256;&#25104;&#21151;&#36825;&#20010;&#25991;&#20214;&#20102;</td></tr><tr class="miss"><td class="line">385</td><td class="hits">0</td><td class="source">					if (index &gt;= count) {</td></tr><tr><td class="line">386</td><td class="hits"></td><td class="source">						// &#32479;&#19968;&#22238;&#35843;,&#25152;&#20197;&#27169;&#25311;&#19968;&#20010;&#36820;&#22238;&#29366;&#24577;</td></tr><tr class="miss"><td class="line">387</td><td class="hits">0</td><td class="source">						fs.unlinkSync(configFile);</td></tr><tr class="miss"><td class="line">388</td><td class="hits">0</td><td class="source">						if (cb) cb(null, null, {</td></tr><tr><td class="line">389</td><td class="hits"></td><td class="source">							statusCode: 200</td></tr><tr><td class="line">390</td><td class="hits"></td><td class="source">						});</td></tr><tr><td class="line">391</td><td class="hits"></td><td class="source">					} else {</td></tr><tr class="miss"><td class="line">392</td><td class="hits">0</td><td class="source">						index = index + 1;</td></tr><tr class="miss"><td class="line">393</td><td class="hits">0</td><td class="source">						nconf.set('list:' + key2, true);</td></tr><tr class="miss"><td class="line">394</td><td class="hits">0</td><td class="source">						nconf.save()</td></tr><tr class="miss"><td class="line">395</td><td class="hits">0</td><td class="source">						barDir.tick();</td></tr><tr class="miss"><td class="line">396</td><td class="hits">0</td><td class="source">						callback();</td></tr><tr><td class="line">397</td><td class="hits"></td><td class="source">					}</td></tr><tr><td class="line">398</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">399</td><td class="hits"></td><td class="source">			})</td></tr><tr><td class="line">400</td><td class="hits"></td><td class="source">		} else {</td></tr><tr class="miss"><td class="line">401</td><td class="hits">0</td><td class="source">			if (cb) {</td></tr><tr class="miss"><td class="line">402</td><td class="hits">0</td><td class="source">				cb({</td></tr><tr><td class="line">403</td><td class="hits"></td><td class="source">					msg: '&#26412;&#25991;&#20214;&#22841;&#19979;&#27809;&#26377;&#35201;&#19978;&#20256;&#30340;&#25991;&#20214;'</td></tr><tr><td class="line">404</td><td class="hits"></td><td class="source">				},</td></tr><tr><td class="line">405</td><td class="hits"></td><td class="source">				null, null);</td></tr><tr><td class="line">406</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">407</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">408</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="miss"><td class="line">409</td><td class="hits">0</td><td class="source">		throw new Error('the file is illegal');</td></tr><tr><td class="line">410</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">411</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">412</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">413</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">414</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">415</td><td class="hits"></td><td class="source">	start: upload</td></tr><tr><td class="line">416</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">417</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="auth.js">auth.js</h2><div id="stats" class="high"><div class="percentage">91%</div><div class="sloc">59</div><div class="hits">54</div><div class="misses">5</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var url = require('url');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var debug = require('debug')('auth');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var crypto = require('crypto');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var config = require('./../config');</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">var encodeWithBase64 = function(s) {</td></tr><tr class="miss"><td class="line">7</td><td class="hits">0</td><td class="source">	var encodedStr = new Buffer(s).toString('base64');</td></tr><tr class="miss"><td class="line">8</td><td class="hits">0</td><td class="source">	return encodedStr;</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">11</td><td class="hits">1</td><td class="source">var hmacSha1 = function(encodedStr, sk) {</td></tr><tr class="hit"><td class="line">12</td><td class="hits">188</td><td class="source">	var hmac = crypto.createHmac('sha1', sk);</td></tr><tr class="hit"><td class="line">13</td><td class="hits">188</td><td class="source">	debug('over')</td></tr><tr class="hit"><td class="line">14</td><td class="hits">188</td><td class="source">	hmac.update(encodedStr);</td></tr><tr class="hit"><td class="line">15</td><td class="hits">188</td><td class="source">	return hmac.digest('base64');</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">19</td><td class="hits">1</td><td class="source">var hmacMd5=function(encodedStr,sk){</td></tr><tr class="miss"><td class="line">20</td><td class="hits">0</td><td class="source">	var hmac = crypto.createHmac('md5', sk);</td></tr><tr class="miss"><td class="line">21</td><td class="hits">0</td><td class="source">	hmac.update(encodedStr);</td></tr><tr class="miss"><td class="line">22</td><td class="hits">0</td><td class="source">	return hmac.digest('base64');</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source"> *  &#20135;&#29983;headers</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> *  CanonicalizedKssHeaders</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">28</td><td class="hits">1</td><td class="source">function generateHeaders(header) {</td></tr><tr class="hit"><td class="line">29</td><td class="hits">186</td><td class="source">	var str = '';</td></tr><tr class="hit"><td class="line">30</td><td class="hits">186</td><td class="source">	var arr = [];</td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">32</td><td class="hits">186</td><td class="source">	if(header){</td></tr><tr class="hit"><td class="line">33</td><td class="hits">138</td><td class="source">		var prefix = 'x-'+config.prefix;</td></tr><tr class="hit"><td class="line">34</td><td class="hits">138</td><td class="source">		for(var it in header){</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">			// step1 : &#25152;&#26377;`x-kss`&#30340;&#23646;&#24615;&#30340;&#38190;&#37117;&#36716;&#25442;&#20026;&#23567;&#20889;&#65292;&#20540;&#19981;&#21464;</td></tr><tr class="hit"><td class="line">36</td><td class="hits">85</td><td class="source">			if(it.indexOf(prefix) == 0){</td></tr><tr class="hit"><td class="line">37</td><td class="hits">6</td><td class="source">				arr.push((it.toLowerCase() +':'+header[it]));</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">		// step2 : &#26681;&#25454;&#23646;&#24615;&#21517;&#25490;&#24207;</td></tr><tr class="hit"><td class="line">41</td><td class="hits">138</td><td class="source">		arr.sort();</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source">		// step3 : &#25340;&#25509;&#36215;&#26469;</td></tr><tr class="hit"><td class="line">43</td><td class="hits">138</td><td class="source">		str = arr.join('\n');</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">45</td><td class="hits">186</td><td class="source">	return str;</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source"> *</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source"> * &#35745;&#31639;&#36890;&#36807; HTTP &#35831;&#27714; Header &#21457;&#36865;&#30340;&#31614;&#21517;</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">52</td><td class="hits">1</td><td class="source">var generateToken = function(sk, req, body) {</td></tr><tr class="hit"><td class="line">53</td><td class="hits">186</td><td class="source">	var urlObj = url.parse(req.uri);</td></tr><tr class="hit"><td class="line">54</td><td class="hits">186</td><td class="source">	var pathObj = urlObj.path;</td></tr><tr class="hit"><td class="line">55</td><td class="hits">186</td><td class="source">	debug('req:', req);</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">57</td><td class="hits">186</td><td class="source">	var http_verb = req.method || 'GET';</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source">	// Content-MD5, Content-Type, CanonicalizedKssHeaders&#21487;&#20026;&#31354;</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">	// Content-MD5 &#34920;&#31034;&#35831;&#27714;&#20869;&#23481;&#25968;&#25454;&#30340;MD5&#20540;, &#20351;&#29992;Base64&#32534;&#30721;</td></tr><tr><td class="line">60</td><td class="hits"></td><td class="source">	//var content_md5 = req.content_md5||'';</td></tr><tr class="hit"><td class="line">61</td><td class="hits">186</td><td class="source">	var content_md5 = (!!req.body)?hmacMd5(req.body,sk):'';</td></tr><tr class="hit"><td class="line">62</td><td class="hits">186</td><td class="source">	var content_type = (typeof req.type!== 'undefined')?req.type : config.contentType;</td></tr><tr class="hit"><td class="line">63</td><td class="hits">186</td><td class="source">	var canonicalized_Kss_Headers = generateHeaders(req.headers);</td></tr><tr class="hit"><td class="line">64</td><td class="hits">186</td><td class="source">	var canonicalized_Resource = req.resource || '/';</td></tr><tr class="hit"><td class="line">65</td><td class="hits">186</td><td class="source">	if (canonicalized_Kss_Headers !== '') {</td></tr><tr class="hit"><td class="line">66</td><td class="hits">6</td><td class="source">		var string2Sign = http_verb + '\n' + content_md5 + '\n' + content_type + '\n' + (req.date) + '\n' + canonicalized_Kss_Headers + '\n' + canonicalized_Resource;</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="hit"><td class="line">68</td><td class="hits">180</td><td class="source">		var string2Sign = http_verb + '\n' + content_md5 + '\n' + content_type + '\n' + (req.date) + '\n' + canonicalized_Resource;</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">71</td><td class="hits">186</td><td class="source">	debug('string2Sign:', string2Sign);</td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">	//console.log('string2Sign:', string2Sign);</td></tr><tr class="hit"><td class="line">73</td><td class="hits">186</td><td class="source">	var digest = hmacSha1(string2Sign, sk);  //&#24050;&#32463;&#32463;&#36807;&#20102;base64&#32534;&#30721;</td></tr><tr class="hit"><td class="line">74</td><td class="hits">186</td><td class="source">	debug('digest:',digest);</td></tr><tr class="hit"><td class="line">75</td><td class="hits">186</td><td class="source">	return digest;</td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source"> * &#22522;&#20110;StringToSign&#29983;&#25104;Signature</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> * @param sk</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source"> * @param stringToSign &#32463;&#36807;Base64&#32534;&#30721;&#30340;policy</td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source"> * @returns {*}</td></tr><tr><td class="line">83</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">84</td><td class="hits">1</td><td class="source">var getSignature = function(sk, stringToSign) {</td></tr><tr class="hit"><td class="line">85</td><td class="hits">2</td><td class="source">	var signature = hmacSha1(stringToSign, sk);</td></tr><tr class="hit"><td class="line">86</td><td class="hits">2</td><td class="source">	return signature;</td></tr><tr><td class="line">87</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">89</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source"> * &#33719;&#21462;Authorization</td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source"> * &#35745;&#31639;&#36890;&#36807; HTTP &#35831;&#27714; Header &#21457;&#36865;&#30340;Authorization&#22836;&#30340;&#20540;</td></tr><tr><td class="line">93</td><td class="hits"></td><td class="source"> * @param ak</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source"> * @param sk</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source"> * @param req</td></tr><tr><td class="line">96</td><td class="hits"></td><td class="source"> * @param body</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source"> * @returns {string}</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">99</td><td class="hits">1</td><td class="source">var generateAuth = function(ak,sk,req, body) {</td></tr><tr class="hit"><td class="line">100</td><td class="hits">184</td><td class="source">	var token = generateToken(sk,req,body);</td></tr><tr class="hit"><td class="line">101</td><td class="hits">184</td><td class="source">	return 'KSS '+ak+':'+ token;</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source"> *</td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source"> * &#36890;&#36807; POST&#35831;&#27714; &#34920;&#21333;&#23454;&#20307; &#21457;&#36865;&#30340;&#31614;&#21517;</td></tr><tr><td class="line">107</td><td class="hits"></td><td class="source"> * @param sk    {string}</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source"> * @param policy {Object}  ex.</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source"> * {</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source">		&quot;expiration&quot;: &quot;2016-02-02T12:12:00.000Z&quot;,</td></tr><tr><td class="line">111</td><td class="hits"></td><td class="source">		&quot;conditions&quot;: [</td></tr><tr><td class="line">112</td><td class="hits"></td><td class="source">			[&quot;eq&quot;, &quot;$bucket&quot;, 'bucket4jssdk'],</td></tr><tr><td class="line">113</td><td class="hits"></td><td class="source">			[&quot;starts-with&quot;, &quot;$key&quot;, &quot;&quot;],</td></tr><tr><td class="line">114</td><td class="hits"></td><td class="source">			[&quot;starts-with&quot;, &quot;$acl&quot;, &quot;public-read&quot;],</td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source">			[&quot;starts-with&quot;, &quot;$name&quot;, &quot;&quot;]   //post&#34920;&#21333;&#20013;&#40664;&#35748;&#20250;&#20256;name&#23383;&#27573;&#65292;&#25925;&#20063;&#38656;&#35201;&#21152;&#21040;policy&#20013;</td></tr><tr><td class="line">116</td><td class="hits"></td><td class="source">		]</td></tr><tr><td class="line">117</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">119</td><td class="hits">1</td><td class="source">var getFormSignature = function(sk, policy) {</td></tr><tr class="hit"><td class="line">120</td><td class="hits">1</td><td class="source">	var stringToSign = new Buffer(JSON.stringify(policy)).toString('base64');</td></tr><tr class="hit"><td class="line">121</td><td class="hits">1</td><td class="source">	var signature = getSignature(sk, stringToSign);</td></tr><tr class="hit"><td class="line">122</td><td class="hits">1</td><td class="source">	return signature;</td></tr><tr><td class="line">123</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">124</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">125</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">126</td><td class="hits"></td><td class="source"> * &#35745;&#31639;&#36890;&#36807;URL QueryString&#21457;&#36865;&#30340;&#31614;&#21517;</td></tr><tr><td class="line">127</td><td class="hits"></td><td class="source"> * @param sk</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source"> * @param expires {number} &#38142;&#25509;&#30340;&#36807;&#26399;&#26102;&#38388;&#65292;&#20351;&#29992;Unix_Time&#34920;&#31034;(s&#20026;&#21333;&#20301;&#65289;</td></tr><tr><td class="line">129</td><td class="hits"></td><td class="source"> * @param bucket bucket name</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source"> * @param object  object key</td></tr><tr><td class="line">131</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">132</td><td class="hits">1</td><td class="source">var getQueryStringSignature = function(sk, expires, bucket, object) {</td></tr><tr class="hit"><td class="line">133</td><td class="hits">1</td><td class="source">	var string2Sign = 'GET' + '\n\n\n' + expires + '\n' + '/' + bucket + '/' + object;</td></tr><tr class="hit"><td class="line">134</td><td class="hits">1</td><td class="source">	var signature = getSignature(sk, string2Sign);</td></tr><tr class="hit"><td class="line">135</td><td class="hits">1</td><td class="source">	return signature;</td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">137</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">138</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">139</td><td class="hits">1</td><td class="source">function isKS3Callback(){}</td></tr><tr><td class="line">140</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">141</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source">	generateHeaders : generateHeaders,</td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source">	generateToken : generateToken,</td></tr><tr><td class="line">144</td><td class="hits"></td><td class="source">	generateAuth : generateAuth,</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source">	getSignature : getSignature,</td></tr><tr><td class="line">146</td><td class="hits"></td><td class="source">	getFormSignature : getFormSignature,</td></tr><tr><td class="line">147</td><td class="hits"></td><td class="source">	getQueryStringSignature : getQueryStringSignature</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">149</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="ks3.js">ks3.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">30</div><div class="hits">30</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var debug = require('debug')('app');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var _service = require('./api/service');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var _bucket = require('./api/bucket');</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var _object = require('./api/object');</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">var config = require('./../config');</td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> * KS3</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">10</td><td class="hits">1</td><td class="source">function KS3(ak, sk, bucket, region) {</td></tr><tr class="hit"><td class="line">11</td><td class="hits">34</td><td class="source">	if ( !! ak &amp;&amp; !! sk) {</td></tr><tr class="hit"><td class="line">12</td><td class="hits">33</td><td class="source">		var core = this;</td></tr><tr class="hit"><td class="line">13</td><td class="hits">33</td><td class="source">		this.ak = ak;</td></tr><tr class="hit"><td class="line">14</td><td class="hits">33</td><td class="source">		this.sk = sk;</td></tr><tr class="hit"><td class="line">15</td><td class="hits">33</td><td class="source">		this.bucketName = bucket || null;</td></tr><tr class="hit"><td class="line">16</td><td class="hits">33</td><td class="source">		if( region ) {</td></tr><tr class="hit"><td class="line">17</td><td class="hits">3</td><td class="source">			config.setRegion(region);</td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">20</td><td class="hits">33</td><td class="source">		['service', 'bucket', 'object', 'upload','download','auth'].forEach(function(name) {</td></tr><tr class="hit"><td class="line">21</td><td class="hits">198</td><td class="source">			var api;</td></tr><tr class="hit"><td class="line">22</td><td class="hits">198</td><td class="source">			if(name != 'auth') {</td></tr><tr class="hit"><td class="line">23</td><td class="hits">165</td><td class="source">				api = require('./api/' + name);</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source">			}else {</td></tr><tr class="hit"><td class="line">25</td><td class="hits">33</td><td class="source">				api = require('./' + name);</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">27</td><td class="hits">198</td><td class="source">			core[name] = {};</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source">			// &#32465;&#23450;this&#21040;&#21508;&#33258;&#20989;&#25968;&#36523;&#19978;</td></tr><tr class="hit"><td class="line">29</td><td class="hits">198</td><td class="source">			for (var attr in api) {</td></tr><tr class="hit"><td class="line">30</td><td class="hits">990</td><td class="source">				core[name][attr] = (function(attr) {</td></tr><tr class="hit"><td class="line">31</td><td class="hits">990</td><td class="source">					return function() {</td></tr><tr class="hit"><td class="line">32</td><td class="hits">202</td><td class="source">						var args = Array.prototype.slice.call(arguments);</td></tr><tr class="hit"><td class="line">33</td><td class="hits">202</td><td class="source">						return api[attr].apply(core, args);</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">					}</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">				})(attr)</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">		});</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="hit"><td class="line">39</td><td class="hits">1</td><td class="source">		throw new Error('require ak and sk. visit: http://ks3.ksyun.com/doc/api/index.html. ak=AccessKeyID,sk=AccessKeySecret');</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> * &#22635;&#20805;&#20449;&#24687;</td></tr><tr><td class="line">45</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">46</td><td class="hits">1</td><td class="source">KS3.version = require('../package.json').version;</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">49</td><td class="hits">1</td><td class="source">KS3.prototype = {</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">	// &#36827;&#34892;&#37197;&#32622;</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">	config: function(cfg) {</td></tr><tr class="hit"><td class="line">52</td><td class="hits">14</td><td class="source">		for (var it in cfg) {</td></tr><tr class="hit"><td class="line">53</td><td class="hits">16</td><td class="source">			config[it] = cfg[it];</td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">58</td><td class="hits">1</td><td class="source">module.exports = KS3;</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="request.js">request.js</h2><div id="stats" class="high"><div class="percentage">95%</div><div class="sloc">41</div><div class="hits">39</div><div class="misses">2</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var urllib = require('urllib');</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var config = require('./../config');</td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">var xml2json = require(&quot;./util&quot;).xml2json;</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">var debug = require('debug')('request');</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">function send(req, body, headers, cb) {</td></tr><tr class="hit"><td class="line">6</td><td class="hits">184</td><td class="source">	var uri = req.uri;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">8</td><td class="hits">184</td><td class="source">	var headers = headers || {};</td></tr><tr class="hit"><td class="line">9</td><td class="hits">184</td><td class="source">	var data = {</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source">		headers: headers,</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">		method: req.method,</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source">		timeout: 1000 * 60 * 60</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">	/**/</td></tr><tr class="hit"><td class="line">16</td><td class="hits">184</td><td class="source">	if (Buffer.isBuffer(body) || typeof body === 'string') {</td></tr><tr class="hit"><td class="line">17</td><td class="hits">83</td><td class="source">		data.content = body;</td></tr><tr class="hit"><td class="line">18</td><td class="hits">101</td><td class="source">	} else if (Object.prototype.toString.call(body) === '[object Object]') {</td></tr><tr class="miss"><td class="line">19</td><td class="hits">0</td><td class="source">		data.data = body;</td></tr><tr class="hit"><td class="line">20</td><td class="hits">101</td><td class="source">	} else if (body) {</td></tr><tr class="miss"><td class="line">21</td><td class="hits">0</td><td class="source">		data.stream = body;</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source">		//data.data = form;</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="hit"><td class="line">24</td><td class="hits">101</td><td class="source">		data.headers['Content-Length'] = 0;</td></tr><tr class="hit"><td class="line">25</td><td class="hits">184</td><td class="source">	};</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">27</td><td class="hits">184</td><td class="source">	debug(data);</td></tr><tr class="hit"><td class="line">28</td><td class="hits">184</td><td class="source">	urllib.request(uri, data, function(err, result, res) {</td></tr><tr class="hit"><td class="line">29</td><td class="hits">184</td><td class="source">		var rerr = null;</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">31</td><td class="hits">184</td><td class="source">		if (err || Math.floor(res.statusCode / 100) !== 2) {</td></tr><tr class="hit"><td class="line">32</td><td class="hits">34</td><td class="source">			rerr = {</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source">				code: res &amp;&amp; res.statusCode || - 1,</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">				error: err || result.error || ''</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">			};</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">37</td><td class="hits">184</td><td class="source">		debug('err',err);</td></tr><tr class="hit"><td class="line">38</td><td class="hits">184</td><td class="source">		debug('res',res);</td></tr><tr class="hit"><td class="line">39</td><td class="hits">184</td><td class="source">		if (cb) {</td></tr><tr class="hit"><td class="line">40</td><td class="hits">153</td><td class="source">			var data = '';</td></tr><tr class="hit"><td class="line">41</td><td class="hits">153</td><td class="source">			if ( !!result) {</td></tr><tr class="hit"><td class="line">42</td><td class="hits">152</td><td class="source">				var dataStr = result.toString();</td></tr><tr class="hit"><td class="line">43</td><td class="hits">152</td><td class="source">				data = dataStr;</td></tr><tr class="hit"><td class="line">44</td><td class="hits">152</td><td class="source">				if (config.dataType === 'json') {</td></tr><tr class="hit"><td class="line">45</td><td class="hits">38</td><td class="source">					dataStr = dataStr.replace(/\s\w+\:\w+=\&quot;\S+\&quot;/g, '');</td></tr><tr class="hit"><td class="line">46</td><td class="hits">38</td><td class="source">					var json = xml2json.parser(dataStr);</td></tr><tr class="hit"><td class="line">47</td><td class="hits">38</td><td class="source">					data = json;</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">50</td><td class="hits">153</td><td class="source">			debug('data',data);</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">			// &#22686;&#21152;&#21407;&#22987;&#25968;&#25454;&#27969;,&#22240;&#20026;&#22312;&#20889;&#25991;&#20214;&#30340;&#26102;&#20505;</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source">			// `buf.toString` &#20250;&#26377;&#38382;&#39064;</td></tr><tr class="hit"><td class="line">53</td><td class="hits">153</td><td class="source">			cb(rerr, data, res,result);</td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">	});</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">59</td><td class="hits">1</td><td class="source">function request(req, body, token, cb) {</td></tr><tr class="hit"><td class="line">60</td><td class="hits">184</td><td class="source">	var headers = {</td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source">		'Content-Type': (typeof req.type !== 'undefined') ? req.type: config.contentType,</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source">		'User-Agent': req.ua || config.ua,</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">		// warning: &#36825;&#20010;&#22320;&#26041;&#38656;&#35201;&#27880;&#24847;,&#22240;&#20026;&#21518;&#31471;&#30340;token&#20135;&#29983;&#38656;&#35201;`date`,&#25152;&#20197;&#38656;&#35201;&#22312;&#35831;&#27714;&#30340;&#26102;&#20505;,&#25226;&#29992;&#20110;&#35745;&#31639;&#25480;&#26435;&#30340;`date`&#20877;&#20256;&#32473;&#21518;&#31471;,</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">		// &#19981;&#33021;&#33258;&#24049;&#29983;&#25104;,&#21542;&#21017;token&#23601;&#25253;&#38169;&#20102;</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">		date: req.date,</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source">		Authorization: token,</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">		'Content-Length': ( !! req.body) ? req.body.length: 0</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">70</td><td class="hits">184</td><td class="source">	if (req.headers) {</td></tr><tr class="hit"><td class="line">71</td><td class="hits">137</td><td class="source">		for (var it in req.headers) {</td></tr><tr class="hit"><td class="line">72</td><td class="hits">84</td><td class="source">			headers[it] = req.headers[it];</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">76</td><td class="hits">184</td><td class="source">	send(req, body, headers, cb);</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">79</td><td class="hits">1</td><td class="source">module.exports = request;</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="util.js">util.js</h2><div id="stats" class="medium"><div class="percentage">71%</div><div class="sloc">232</div><div class="hits">165</div><div class="misses">67</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var fs = require('fs');</td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source"> * &#26657;&#39564;bucketName&#30340;&#21487;&#29992;&#24615;</td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">function verifyBucket(name) {</td></tr><tr class="hit"><td class="line">6</td><td class="hits">34</td><td class="source">	var flag = true;</td></tr><tr class="hit"><td class="line">7</td><td class="hits">34</td><td class="source">	var len = name.length;</td></tr><tr class="hit"><td class="line">8</td><td class="hits">34</td><td class="source">	var re = /^[a-z0-9]+([\.-]*([a-z0-9])*)*[a-z0-9]+$/;</td></tr><tr class="hit"><td class="line">9</td><td class="hits">34</td><td class="source">	if (len &gt;= 3 &amp;&amp; len &lt;= 63) {</td></tr><tr class="hit"><td class="line">10</td><td class="hits">34</td><td class="source">		flag = re.test(name)</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">	} else {</td></tr><tr class="miss"><td class="line">12</td><td class="hits">0</td><td class="source">		flag = false;</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">14</td><td class="hits">34</td><td class="source">	return flag;</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source"> * &#39564;&#35777;ACL&#26435;&#38480;</td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">19</td><td class="hits">1</td><td class="source">function verifyAcl(acl) {</td></tr><tr class="hit"><td class="line">20</td><td class="hits">8</td><td class="source">	var flag = null;</td></tr><tr class="hit"><td class="line">21</td><td class="hits">8</td><td class="source">	var acls = ['private', 'public-read', 'public-read-write', 'authenticated-read', 'bucket-owner-read', 'bucket-owner-full-control'];</td></tr><tr class="hit"><td class="line">22</td><td class="hits">8</td><td class="source">	var reg = new RegExp('^' + acl + '$', 'i');</td></tr><tr class="hit"><td class="line">23</td><td class="hits">8</td><td class="source">	acls.forEach(function(name) {</td></tr><tr class="hit"><td class="line">24</td><td class="hits">48</td><td class="source">		if (reg.test(name)) {</td></tr><tr class="hit"><td class="line">25</td><td class="hits">6</td><td class="source">			flag = name.toLowerCase();</td></tr><tr class="hit"><td class="line">26</td><td class="hits">6</td><td class="source">			return flag;</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source">	})</td></tr><tr class="hit"><td class="line">29</td><td class="hits">8</td><td class="source">	return flag;</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source"> * key &#36827;&#34892;encodeURIComponent&#32534;&#30721;&#65292;'/'&#19981;&#33021;&#34987;&#32534;&#30721;</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">34</td><td class="hits">1</td><td class="source">function encodeKey(key) {</td></tr><tr class="hit"><td class="line">35</td><td class="hits">148</td><td class="source">	var newKey = encodeURIComponent(key);</td></tr><tr class="hit"><td class="line">36</td><td class="hits">148</td><td class="source">	return newKey.replace(/%2F/g, '/');</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">	// return key</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source"> * &#36941;&#21382;&#25991;&#20214;</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">43</td><td class="hits">1</td><td class="source">function walkFile(p, opt, fileList) {</td></tr><tr class="hit"><td class="line">44</td><td class="hits">4</td><td class="source">	var fileList = fileList || [];</td></tr><tr class="hit"><td class="line">45</td><td class="hits">4</td><td class="source">	var _config = {</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">		isDeep: false,</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source">		ignore: /\s/ig</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">	};</td></tr><tr class="hit"><td class="line">49</td><td class="hits">4</td><td class="source">	var dirList = fs.readdirSync(p);</td></tr><tr class="hit"><td class="line">50</td><td class="hits">4</td><td class="source">	for (var it in opt) {</td></tr><tr class="hit"><td class="line">51</td><td class="hits">8</td><td class="source">		_config[it] = opt[it];</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">53</td><td class="hits">4</td><td class="source">	dirList.forEach(function(item) {</td></tr><tr class="hit"><td class="line">54</td><td class="hits">10</td><td class="source">		if (!_config.ignore.test(item)) {</td></tr><tr class="hit"><td class="line">55</td><td class="hits">10</td><td class="source">			if (_config.isDeep) {</td></tr><tr class="hit"><td class="line">56</td><td class="hits">7</td><td class="source">				if (fs.statSync(p + '/' + item).isDirectory()) {</td></tr><tr class="hit"><td class="line">57</td><td class="hits">2</td><td class="source">					fileList.push(p + '/' + item);</td></tr><tr class="hit"><td class="line">58</td><td class="hits">2</td><td class="source">					walkFile(p + '/' + item, opt, fileList);</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">				} else {</td></tr><tr class="hit"><td class="line">60</td><td class="hits">5</td><td class="source">					fileList.push(p + '/' + item);</td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source">			} else {</td></tr><tr class="hit"><td class="line">63</td><td class="hits">3</td><td class="source">				fileList.push(p + '/' + item);</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">	});</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">69</td><td class="hits">4</td><td class="source">	return fileList;</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">/**</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source"> * &#36941;&#21382;&#25991;&#20214;&#22841;</td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source"> */</td></tr><tr class="hit"><td class="line">75</td><td class="hits">1</td><td class="source">function walkDir(p, opt) {</td></tr><tr class="miss"><td class="line">76</td><td class="hits">0</td><td class="source">	var fileList = walkFile(p, opt);</td></tr><tr class="miss"><td class="line">77</td><td class="hits">0</td><td class="source">	var dirList = [];</td></tr><tr class="miss"><td class="line">78</td><td class="hits">0</td><td class="source">	fileList.forEach(function(item) {</td></tr><tr class="miss"><td class="line">79</td><td class="hits">0</td><td class="source">		if (fs.statSync(item).isDirectory()) {</td></tr><tr class="miss"><td class="line">80</td><td class="hits">0</td><td class="source">			dirList.push(item);</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source">	});</td></tr><tr><td class="line">83</td><td class="hits"></td><td class="source"> </td></tr><tr class="miss"><td class="line">84</td><td class="hits">0</td><td class="source">	return dirList;</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">86</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">87</td><td class="hits"></td><td class="source">/*</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">xml2json v 1.1</td></tr><tr><td class="line">89</td><td class="hits"></td><td class="source">copyright 2005-2007 Thomas Frank</td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source">This program is free software under the terms of the </td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source">GNU General Public License version 2 as published by the Free </td></tr><tr><td class="line">93</td><td class="hits"></td><td class="source">Software Foundation. It is distributed without any warranty.</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source">*/</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">96</td><td class="hits">1</td><td class="source">var xml2json = {</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">	parser: function(xmlcode, ignoretags, debug) {</td></tr><tr class="hit"><td class="line">98</td><td class="hits">38</td><td class="source">		if (!ignoretags) {</td></tr><tr class="hit"><td class="line">99</td><td class="hits">38</td><td class="source">			ignoretags = &quot;&quot;</td></tr><tr class="hit"><td class="line">100</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">101</td><td class="hits">38</td><td class="source">		xmlcode = xmlcode.replace(/\s*\/&gt;/g, '/&gt;');</td></tr><tr class="hit"><td class="line">102</td><td class="hits">38</td><td class="source">		xmlcode = xmlcode.replace(/&lt;\?[^&gt;]*&gt;/g, &quot;&quot;).replace(/&lt;\![^&gt;]*&gt;/g, &quot;&quot;);</td></tr><tr class="hit"><td class="line">103</td><td class="hits">38</td><td class="source">		if (!ignoretags.sort) {</td></tr><tr class="hit"><td class="line">104</td><td class="hits">38</td><td class="source">			ignoretags = ignoretags.split(&quot;,&quot;)</td></tr><tr class="hit"><td class="line">105</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">106</td><td class="hits">38</td><td class="source">		var x = this.no_fast_endings(xmlcode);</td></tr><tr class="hit"><td class="line">107</td><td class="hits">38</td><td class="source">		x = this.attris_to_tags(x);</td></tr><tr class="hit"><td class="line">108</td><td class="hits">38</td><td class="source">		x = escape(x);</td></tr><tr class="hit"><td class="line">109</td><td class="hits">38</td><td class="source">		x = x.split(&quot;%3C&quot;).join(&quot;&lt;&quot;).split(&quot;%3E&quot;).join(&quot;&gt;&quot;).split(&quot;%3D&quot;).join(&quot;=&quot;).split(&quot;%22&quot;).join(&quot;\&quot;&quot;);</td></tr><tr class="hit"><td class="line">110</td><td class="hits">38</td><td class="source">		for (var i = 0; i &lt; ignoretags.length; i++) {</td></tr><tr class="hit"><td class="line">111</td><td class="hits">38</td><td class="source">			x = x.replace(new RegExp(&quot;&lt;&quot; + ignoretags[i] + &quot;&gt;&quot;, &quot;g&quot;), &quot;*$**&quot; + ignoretags[i] + &quot;**$*&quot;);</td></tr><tr class="hit"><td class="line">112</td><td class="hits">38</td><td class="source">			x = x.replace(new RegExp(&quot;&lt;/&quot; + ignoretags[i] + &quot;&gt;&quot;, &quot;g&quot;), &quot;*$***&quot; + ignoretags[i] + &quot;**$*&quot;)</td></tr><tr class="hit"><td class="line">113</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">114</td><td class="hits">38</td><td class="source">		x = '&lt;JSONTAGWRAPPER&gt;' + x + '&lt;/JSONTAGWRAPPER&gt;';</td></tr><tr class="hit"><td class="line">115</td><td class="hits">38</td><td class="source">		this.xmlobject = {};</td></tr><tr class="hit"><td class="line">116</td><td class="hits">38</td><td class="source">		var y = this.xml_to_object(x).jsontagwrapper;</td></tr><tr class="hit"><td class="line">117</td><td class="hits">38</td><td class="source">		if (debug) {</td></tr><tr class="miss"><td class="line">118</td><td class="hits">0</td><td class="source">			y = this.show_json_structure(y, debug)</td></tr><tr class="hit"><td class="line">119</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">120</td><td class="hits">38</td><td class="source">		return y</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source">	},</td></tr><tr><td class="line">122</td><td class="hits"></td><td class="source">	xml_to_object: function(xmlcode) {</td></tr><tr class="hit"><td class="line">123</td><td class="hits">38</td><td class="source">		var x = xmlcode.replace(/&lt;\//g, &quot;&#167;&quot;);</td></tr><tr class="hit"><td class="line">124</td><td class="hits">38</td><td class="source">		x = x.split(&quot;&lt;&quot;);</td></tr><tr class="hit"><td class="line">125</td><td class="hits">38</td><td class="source">		var y = [];</td></tr><tr class="hit"><td class="line">126</td><td class="hits">38</td><td class="source">		var level = 0;</td></tr><tr class="hit"><td class="line">127</td><td class="hits">38</td><td class="source">		var opentags = [];</td></tr><tr class="hit"><td class="line">128</td><td class="hits">38</td><td class="source">		for (var i = 1; i &lt; x.length; i++) {</td></tr><tr class="hit"><td class="line">129</td><td class="hits">89</td><td class="source">			var tagname = x[i].split(&quot;&gt;&quot;)[0];</td></tr><tr class="hit"><td class="line">130</td><td class="hits">89</td><td class="source">			opentags.push(tagname);</td></tr><tr class="hit"><td class="line">131</td><td class="hits">89</td><td class="source">			level++;</td></tr><tr class="hit"><td class="line">132</td><td class="hits">89</td><td class="source">			y.push(level + &quot;&lt;&quot; + x[i].split(&quot;&#167;&quot;)[0]);</td></tr><tr class="hit"><td class="line">133</td><td class="hits">89</td><td class="source">			while (x[i].indexOf(&quot;&#167;&quot; + opentags[opentags.length - 1] + &quot;&gt;&quot;) &gt;= 0) {</td></tr><tr class="hit"><td class="line">134</td><td class="hits">89</td><td class="source">				level--;</td></tr><tr class="hit"><td class="line">135</td><td class="hits">89</td><td class="source">				opentags.pop()</td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">137</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">138</td><td class="hits">38</td><td class="source">		var oldniva = - 1;</td></tr><tr class="hit"><td class="line">139</td><td class="hits">38</td><td class="source">		var objname = &quot;this.xmlobject&quot;;</td></tr><tr class="hit"><td class="line">140</td><td class="hits">38</td><td class="source">		for (var i = 0; i &lt; y.length; i++) {</td></tr><tr class="hit"><td class="line">141</td><td class="hits">89</td><td class="source">			var preeval = &quot;&quot;;</td></tr><tr class="hit"><td class="line">142</td><td class="hits">89</td><td class="source">			var niva = y[i].split(&quot;&lt;&quot;)[0];</td></tr><tr class="hit"><td class="line">143</td><td class="hits">89</td><td class="source">			var tagnamn = y[i].split(&quot;&lt;&quot;)[1].split(&quot;&gt;&quot;)[0];</td></tr><tr class="hit"><td class="line">144</td><td class="hits">89</td><td class="source">			tagnamn = tagnamn == 'JSONTAGWRAPPER' ? tagnamn.toLowerCase() : tagnamn;</td></tr><tr class="hit"><td class="line">145</td><td class="hits">89</td><td class="source">			var rest = y[i].split(&quot;&gt;&quot;)[1];</td></tr><tr class="hit"><td class="line">146</td><td class="hits">89</td><td class="source">			if (niva &lt;= oldniva) {</td></tr><tr class="hit"><td class="line">147</td><td class="hits">29</td><td class="source">				var tabort = oldniva - niva + 1;</td></tr><tr class="hit"><td class="line">148</td><td class="hits">29</td><td class="source">				for (var j = 0; j &lt; tabort; j++) {</td></tr><tr class="hit"><td class="line">149</td><td class="hits">33</td><td class="source">					objname = objname.substring(0, objname.lastIndexOf(&quot;.&quot;))</td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source">				}</td></tr><tr class="hit"><td class="line">151</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">152</td><td class="hits">89</td><td class="source">			objname += &quot;.&quot; + tagnamn;</td></tr><tr class="hit"><td class="line">153</td><td class="hits">89</td><td class="source">			var pobject = objname.substring(0, objname.lastIndexOf(&quot;.&quot;));</td></tr><tr class="hit"><td class="line">154</td><td class="hits">89</td><td class="source">			if (eval(&quot;typeof &quot; + pobject) != &quot;object&quot;) {</td></tr><tr class="miss"><td class="line">155</td><td class="hits">0</td><td class="source">				preeval += pobject + &quot;={value:&quot; + pobject + &quot;};\n&quot;</td></tr><tr class="hit"><td class="line">156</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">157</td><td class="hits">89</td><td class="source">			var objlast = objname.substring(objname.lastIndexOf(&quot;.&quot;) + 1);</td></tr><tr class="hit"><td class="line">158</td><td class="hits">89</td><td class="source">			var already = false;</td></tr><tr class="hit"><td class="line">159</td><td class="hits">89</td><td class="source">			for (k in eval(pobject)) {</td></tr><tr class="hit"><td class="line">160</td><td class="hits">54</td><td class="source">				if (k == objlast) {</td></tr><tr class="hit"><td class="line">161</td><td class="hits">1</td><td class="source">					already = true</td></tr><tr><td class="line">162</td><td class="hits"></td><td class="source">				}</td></tr><tr class="hit"><td class="line">163</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">164</td><td class="hits">89</td><td class="source">			var onlywhites = true;</td></tr><tr class="hit"><td class="line">165</td><td class="hits">89</td><td class="source">			for (var s = 0; s &lt; rest.length; s += 3) {</td></tr><tr class="hit"><td class="line">166</td><td class="hits">314</td><td class="source">				if (rest.charAt(s) != &quot;%&quot;) {</td></tr><tr class="hit"><td class="line">167</td><td class="hits">314</td><td class="source">					onlywhites = false</td></tr><tr><td class="line">168</td><td class="hits"></td><td class="source">				}</td></tr><tr class="hit"><td class="line">169</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">170</td><td class="hits">89</td><td class="source">			if (rest != &quot;&quot; &amp;&amp; ! onlywhites) {</td></tr><tr class="hit"><td class="line">171</td><td class="hits">37</td><td class="source">				if (rest / 1 != rest) {</td></tr><tr class="hit"><td class="line">172</td><td class="hits">37</td><td class="source">					rest = &quot;'&quot; + rest.replace(/\'/g, &quot;\\'&quot;) + &quot;'&quot;;</td></tr><tr class="hit"><td class="line">173</td><td class="hits">37</td><td class="source">					rest = rest.replace(/\*\$\*\*\*/g, &quot;&lt;/&quot;);</td></tr><tr class="hit"><td class="line">174</td><td class="hits">37</td><td class="source">					rest = rest.replace(/\*\$\*\*/g, &quot;&lt;&quot;);</td></tr><tr class="hit"><td class="line">175</td><td class="hits">37</td><td class="source">					rest = rest.replace(/\*\*\$\*/g, &quot;&gt;&quot;)</td></tr><tr><td class="line">176</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">178</td><td class="hits"></td><td class="source">			else {</td></tr><tr class="hit"><td class="line">179</td><td class="hits">52</td><td class="source">				rest = &quot;{}&quot;</td></tr><tr class="hit"><td class="line">180</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">181</td><td class="hits">89</td><td class="source">			if (rest.charAt(0) == &quot;'&quot;) {</td></tr><tr class="hit"><td class="line">182</td><td class="hits">37</td><td class="source">				rest = 'unescape(' + rest + ')'</td></tr><tr class="hit"><td class="line">183</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">184</td><td class="hits">89</td><td class="source">			if (already &amp;&amp; ! eval(objname + &quot;.sort&quot;)) {</td></tr><tr class="hit"><td class="line">185</td><td class="hits">1</td><td class="source">				preeval += objname + &quot;=[&quot; + objname + &quot;];\n&quot;</td></tr><tr class="hit"><td class="line">186</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">187</td><td class="hits">89</td><td class="source">			var before = &quot;=&quot;;</td></tr><tr class="hit"><td class="line">188</td><td class="hits">89</td><td class="source">			after = &quot;&quot;;</td></tr><tr class="hit"><td class="line">189</td><td class="hits">89</td><td class="source">			if (already) {</td></tr><tr class="hit"><td class="line">190</td><td class="hits">1</td><td class="source">				before = &quot;.push(&quot;;</td></tr><tr class="hit"><td class="line">191</td><td class="hits">1</td><td class="source">				after = &quot;)&quot;</td></tr><tr class="hit"><td class="line">192</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">193</td><td class="hits">89</td><td class="source">			var toeval = preeval + objname + before + rest + after;</td></tr><tr class="hit"><td class="line">194</td><td class="hits">89</td><td class="source">			eval(toeval);</td></tr><tr class="hit"><td class="line">195</td><td class="hits">89</td><td class="source">			if (eval(objname + &quot;.sort&quot;)) {</td></tr><tr class="hit"><td class="line">196</td><td class="hits">1</td><td class="source">				objname += &quot;[&quot; + eval(objname + &quot;.length-1&quot;) + &quot;]&quot;</td></tr><tr class="hit"><td class="line">197</td><td class="hits">89</td><td class="source">			};</td></tr><tr class="hit"><td class="line">198</td><td class="hits">89</td><td class="source">			oldniva = niva</td></tr><tr class="hit"><td class="line">199</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">200</td><td class="hits">38</td><td class="source">		return this.xmlobject</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source">	},</td></tr><tr><td class="line">202</td><td class="hits"></td><td class="source">	show_json_structure: function(obj, debug, l) {</td></tr><tr class="miss"><td class="line">203</td><td class="hits">0</td><td class="source">		var x = '';</td></tr><tr class="miss"><td class="line">204</td><td class="hits">0</td><td class="source">		if (obj.sort) {</td></tr><tr class="miss"><td class="line">205</td><td class="hits">0</td><td class="source">			x += &quot;[\n&quot;</td></tr><tr><td class="line">206</td><td class="hits"></td><td class="source">		} else {</td></tr><tr class="miss"><td class="line">207</td><td class="hits">0</td><td class="source">			x += &quot;{\n&quot;</td></tr><tr class="miss"><td class="line">208</td><td class="hits">0</td><td class="source">		};</td></tr><tr class="miss"><td class="line">209</td><td class="hits">0</td><td class="source">		for (var i in obj) {</td></tr><tr class="miss"><td class="line">210</td><td class="hits">0</td><td class="source">			if (!obj.sort) {</td></tr><tr class="miss"><td class="line">211</td><td class="hits">0</td><td class="source">				x += i + &quot;:&quot;</td></tr><tr class="miss"><td class="line">212</td><td class="hits">0</td><td class="source">			};</td></tr><tr class="miss"><td class="line">213</td><td class="hits">0</td><td class="source">			if (typeof obj[i] == &quot;object&quot;) {</td></tr><tr class="miss"><td class="line">214</td><td class="hits">0</td><td class="source">				x += this.show_json_structure(obj[i], false, 1)</td></tr><tr><td class="line">215</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">216</td><td class="hits"></td><td class="source">			else {</td></tr><tr class="miss"><td class="line">217</td><td class="hits">0</td><td class="source">				if (typeof obj[i] == &quot;function&quot;) {</td></tr><tr class="miss"><td class="line">218</td><td class="hits">0</td><td class="source">					var v = obj[i] + &quot;&quot;;</td></tr><tr><td class="line">219</td><td class="hits"></td><td class="source">					//v=v.replace(/\t/g,&quot;&quot;);</td></tr><tr class="miss"><td class="line">220</td><td class="hits">0</td><td class="source">					x += v</td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source">				}</td></tr><tr class="miss"><td class="line">222</td><td class="hits">0</td><td class="source">				else if (typeof obj[i] != &quot;string&quot;) {</td></tr><tr class="miss"><td class="line">223</td><td class="hits">0</td><td class="source">					x += obj[i] + &quot;,\n&quot;</td></tr><tr><td class="line">224</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">225</td><td class="hits"></td><td class="source">				else {</td></tr><tr class="miss"><td class="line">226</td><td class="hits">0</td><td class="source">					x += &quot;'&quot; + obj[i].replace(/\'/g, &quot;\\'&quot;).replace(/\n/g, &quot;\\n&quot;).replace(/\t/g, &quot;\\t&quot;).replace(/\r/g, &quot;\\r&quot;) + &quot;',\n&quot;</td></tr><tr><td class="line">227</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">228</td><td class="hits"></td><td class="source">			}</td></tr><tr class="miss"><td class="line">229</td><td class="hits">0</td><td class="source">		};</td></tr><tr class="miss"><td class="line">230</td><td class="hits">0</td><td class="source">		if (obj.sort) {</td></tr><tr class="miss"><td class="line">231</td><td class="hits">0</td><td class="source">			x += &quot;],\n&quot;</td></tr><tr><td class="line">232</td><td class="hits"></td><td class="source">		} else {</td></tr><tr class="miss"><td class="line">233</td><td class="hits">0</td><td class="source">			x += &quot;},\n&quot;</td></tr><tr class="miss"><td class="line">234</td><td class="hits">0</td><td class="source">		};</td></tr><tr class="miss"><td class="line">235</td><td class="hits">0</td><td class="source">		if (!l) {</td></tr><tr class="miss"><td class="line">236</td><td class="hits">0</td><td class="source">			x = x.substring(0, x.lastIndexOf(&quot;,&quot;));</td></tr><tr class="miss"><td class="line">237</td><td class="hits">0</td><td class="source">			x = x.replace(new RegExp(&quot;,\n}&quot;, &quot;g&quot;), &quot;\n}&quot;);</td></tr><tr class="miss"><td class="line">238</td><td class="hits">0</td><td class="source">			x = x.replace(new RegExp(&quot;,\n]&quot;, &quot;g&quot;), &quot;\n]&quot;);</td></tr><tr class="miss"><td class="line">239</td><td class="hits">0</td><td class="source">			var y = x.split(&quot;\n&quot;);</td></tr><tr class="miss"><td class="line">240</td><td class="hits">0</td><td class="source">			x = &quot;&quot;;</td></tr><tr class="miss"><td class="line">241</td><td class="hits">0</td><td class="source">			var lvl = 0;</td></tr><tr class="miss"><td class="line">242</td><td class="hits">0</td><td class="source">			for (var i = 0; i &lt; y.length; i++) {</td></tr><tr class="miss"><td class="line">243</td><td class="hits">0</td><td class="source">				if (y[i].indexOf(&quot;}&quot;) &gt;= 0 || y[i].indexOf(&quot;]&quot;) &gt;= 0) {</td></tr><tr class="miss"><td class="line">244</td><td class="hits">0</td><td class="source">					lvl--</td></tr><tr class="miss"><td class="line">245</td><td class="hits">0</td><td class="source">				};</td></tr><tr class="miss"><td class="line">246</td><td class="hits">0</td><td class="source">				tabs = &quot;&quot;;</td></tr><tr class="miss"><td class="line">247</td><td class="hits">0</td><td class="source">				for (var j = 0; j &lt; lvl; j++) {</td></tr><tr class="miss"><td class="line">248</td><td class="hits">0</td><td class="source">					tabs += &quot;\t&quot;</td></tr><tr class="miss"><td class="line">249</td><td class="hits">0</td><td class="source">				};</td></tr><tr class="miss"><td class="line">250</td><td class="hits">0</td><td class="source">				x += tabs + y[i] + &quot;\n&quot;;</td></tr><tr class="miss"><td class="line">251</td><td class="hits">0</td><td class="source">				if (y[i].indexOf(&quot;{&quot;) &gt;= 0 || y[i].indexOf(&quot;[&quot;) &gt;= 0) {</td></tr><tr class="miss"><td class="line">252</td><td class="hits">0</td><td class="source">					lvl++</td></tr><tr><td class="line">253</td><td class="hits"></td><td class="source">				}</td></tr><tr class="miss"><td class="line">254</td><td class="hits">0</td><td class="source">			};</td></tr><tr class="miss"><td class="line">255</td><td class="hits">0</td><td class="source">			if (debug == &quot;html&quot;) {</td></tr><tr class="miss"><td class="line">256</td><td class="hits">0</td><td class="source">				x = x.replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;);</td></tr><tr class="miss"><td class="line">257</td><td class="hits">0</td><td class="source">				x = x.replace(/\n/g, &quot;&lt;BR&gt;&quot;).replace(/\t/g, &quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;)</td></tr><tr class="miss"><td class="line">258</td><td class="hits">0</td><td class="source">			};</td></tr><tr class="miss"><td class="line">259</td><td class="hits">0</td><td class="source">			if (debug == &quot;compact&quot;) {</td></tr><tr class="miss"><td class="line">260</td><td class="hits">0</td><td class="source">				x = x.replace(/\n/g, &quot;&quot;).replace(/\t/g, &quot;&quot;)</td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source">			}</td></tr><tr class="miss"><td class="line">262</td><td class="hits">0</td><td class="source">		};</td></tr><tr class="miss"><td class="line">263</td><td class="hits">0</td><td class="source">		return x</td></tr><tr><td class="line">264</td><td class="hits"></td><td class="source">	},</td></tr><tr><td class="line">265</td><td class="hits"></td><td class="source">	no_fast_endings: function(x) {</td></tr><tr class="hit"><td class="line">266</td><td class="hits">38</td><td class="source">		x = x.split(&quot;/&gt;&quot;);</td></tr><tr class="hit"><td class="line">267</td><td class="hits">38</td><td class="source">		for (var i = 1; i &lt; x.length; i++) {</td></tr><tr class="miss"><td class="line">268</td><td class="hits">0</td><td class="source">			var t = x[i - 1].substring(x[i - 1].lastIndexOf(&quot;&lt;&quot;) + 1).split(&quot; &quot;)[0];</td></tr><tr class="miss"><td class="line">269</td><td class="hits">0</td><td class="source">			x[i] = &quot;&gt;&lt;/&quot; + t + &quot;&gt;&quot; + x[i]</td></tr><tr class="hit"><td class="line">270</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">271</td><td class="hits">38</td><td class="source">		x = x.join(&quot;&quot;);</td></tr><tr class="hit"><td class="line">272</td><td class="hits">38</td><td class="source">		return x</td></tr><tr><td class="line">273</td><td class="hits"></td><td class="source">	},</td></tr><tr><td class="line">274</td><td class="hits"></td><td class="source">	attris_to_tags: function(x) {</td></tr><tr class="hit"><td class="line">275</td><td class="hits">38</td><td class="source">		var d = ' =&quot;\''.split(&quot;&quot;);</td></tr><tr class="hit"><td class="line">276</td><td class="hits">38</td><td class="source">		x = x.split(&quot;&gt;&quot;);</td></tr><tr class="hit"><td class="line">277</td><td class="hits">38</td><td class="source">		for (var i = 0; i &lt; x.length; i++) {</td></tr><tr class="hit"><td class="line">278</td><td class="hits">124</td><td class="source">			var temp = x[i].split(&quot;&lt;&quot;);</td></tr><tr class="hit"><td class="line">279</td><td class="hits">124</td><td class="source">			for (var r = 0; r &lt; 4; r++) {</td></tr><tr class="hit"><td class="line">280</td><td class="hits">496</td><td class="source">				temp[0] = temp[0].replace(new RegExp(d[r], &quot;g&quot;), &quot;_jsonconvtemp&quot; + r + &quot;_&quot;)</td></tr><tr class="hit"><td class="line">281</td><td class="hits">124</td><td class="source">			};</td></tr><tr class="hit"><td class="line">282</td><td class="hits">124</td><td class="source">			if (temp[1]) {</td></tr><tr class="hit"><td class="line">283</td><td class="hits">86</td><td class="source">				temp[1] = temp[1].replace(/'/g, '&quot;');</td></tr><tr class="hit"><td class="line">284</td><td class="hits">86</td><td class="source">				temp[1] = temp[1].split('&quot;');</td></tr><tr class="hit"><td class="line">285</td><td class="hits">86</td><td class="source">				for (var j = 1; j &lt; temp[1].length; j += 2) {</td></tr><tr class="hit"><td class="line">286</td><td class="hits">8</td><td class="source">					for (var r = 0; r &lt; 4; r++) {</td></tr><tr class="hit"><td class="line">287</td><td class="hits">32</td><td class="source">						temp[1][j] = temp[1][j].replace(new RegExp(d[r], &quot;g&quot;), &quot;_jsonconvtemp&quot; + r + &quot;_&quot;)</td></tr><tr><td class="line">288</td><td class="hits"></td><td class="source">					}</td></tr><tr class="hit"><td class="line">289</td><td class="hits">86</td><td class="source">				};</td></tr><tr class="hit"><td class="line">290</td><td class="hits">86</td><td class="source">				temp[1] = temp[1].join('&quot;')</td></tr><tr class="hit"><td class="line">291</td><td class="hits">124</td><td class="source">			};</td></tr><tr class="hit"><td class="line">292</td><td class="hits">124</td><td class="source">			x[i] = temp.join(&quot;&lt;&quot;)</td></tr><tr class="hit"><td class="line">293</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">294</td><td class="hits">38</td><td class="source">		x = x.join(&quot;&gt;&quot;);</td></tr><tr class="hit"><td class="line">295</td><td class="hits">38</td><td class="source">		x = x.replace(/ ([^=]*)=([^ |&gt;]*)/g, &quot;&gt;&lt;$1&gt;$2&lt;/$1&quot;);</td></tr><tr class="hit"><td class="line">296</td><td class="hits">38</td><td class="source">		x = x.replace(/&gt;&quot;/g, &quot;&gt;&quot;).replace(/&quot;&lt;/g, &quot;&lt;&quot;);</td></tr><tr class="hit"><td class="line">297</td><td class="hits">38</td><td class="source">		for (var r = 0; r &lt; 4; r++) {</td></tr><tr class="hit"><td class="line">298</td><td class="hits">152</td><td class="source">			x = x.replace(new RegExp(&quot;_jsonconvtemp&quot; + r + &quot;_&quot;, &quot;g&quot;), d[r])</td></tr><tr class="hit"><td class="line">299</td><td class="hits">38</td><td class="source">		};</td></tr><tr class="hit"><td class="line">300</td><td class="hits">38</td><td class="source">		return x</td></tr><tr><td class="line">301</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">302</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">303</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">304</td><td class="hits">1</td><td class="source">if (!Array.prototype.push) {</td></tr><tr class="miss"><td class="line">305</td><td class="hits">0</td><td class="source">	Array.prototype.push = function(x) {</td></tr><tr class="miss"><td class="line">306</td><td class="hits">0</td><td class="source">		this[this.length] = x;</td></tr><tr class="miss"><td class="line">307</td><td class="hits">0</td><td class="source">		return true</td></tr><tr><td class="line">308</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">309</td><td class="hits">1</td><td class="source">};</td></tr><tr><td class="line">310</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">311</td><td class="hits">1</td><td class="source">if (!Array.prototype.pop) {</td></tr><tr class="miss"><td class="line">312</td><td class="hits">0</td><td class="source">	Array.prototype.pop = function() {</td></tr><tr class="miss"><td class="line">313</td><td class="hits">0</td><td class="source">		var response = this[this.length - 1];</td></tr><tr class="miss"><td class="line">314</td><td class="hits">0</td><td class="source">		this.length--;</td></tr><tr class="miss"><td class="line">315</td><td class="hits">0</td><td class="source">		return response</td></tr><tr><td class="line">316</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">317</td><td class="hits">1</td><td class="source">};</td></tr><tr><td class="line">318</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">319</td><td class="hits">1</td><td class="source">module.exports = {</td></tr><tr><td class="line">320</td><td class="hits"></td><td class="source">	verifyBucket: verifyBucket,</td></tr><tr><td class="line">321</td><td class="hits"></td><td class="source">	verifyAcl: verifyAcl,</td></tr><tr><td class="line">322</td><td class="hits"></td><td class="source">	encodeKey: encodeKey,</td></tr><tr><td class="line">323</td><td class="hits"></td><td class="source">	walkFile: walkFile,</td></tr><tr><td class="line">324</td><td class="hits"></td><td class="source">	walkDir: walkDir,</td></tr><tr><td class="line">325</td><td class="hits"></td><td class="source">	xml2json: xml2json,</td></tr><tr><td class="line">326</td><td class="hits"></td><td class="source">	getDate: function() {</td></tr><tr class="hit"><td class="line">327</td><td class="hits">142</td><td class="source">		return (new Date()).toUTCString();</td></tr><tr><td class="line">328</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">329</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">330</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div></div></div></body></html>